:root {
  --bg: #07041a;
  --bg2: #150a3a;
  --violet: #7b4dff;
  --magenta: #d14dff;
  --cyan: #5ee7ff;
  --gold: #f5c96b;
  --gold-2: #ffe7a8;
  --gold-3: #b8862f;
  --text: #f1eaff;
  --muted: #b3a6d9;
  --glass: rgba(30, 16, 70, 0.55);
  --line: rgba(245, 201, 107, 0.35);
  --size: min(78vmin, 560px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 40%, var(--bg2) 0%, var(--bg) 70%);
  color: var(--text);
  font-family: "Kanit", system-ui, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

/* ---------- ฉากหลัง ---------- */
#stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.nebula {
  position: fixed; inset: -20%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 30% at 20% 30%, rgba(123, 77, 255, .28), transparent 70%),
    radial-gradient(35% 30% at 80% 70%, rgba(209, 77, 255, .22), transparent 70%),
    radial-gradient(30% 25% at 70% 20%, rgba(94, 231, 255, .12), transparent 70%);
  filter: blur(30px);
  animation: drift 30s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(4%, -3%) rotate(8deg) scale(1.08); } }

/* ---------- อินโทร ---------- */
.intro {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: var(--bg);
  transition: opacity 1s ease, visibility 1s;
}
.intro.done { opacity: 0; visibility: hidden; }
.portal { position: relative; width: 220px; height: 220px; }
.portal span {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--gold); border-bottom-color: var(--magenta);
  animation: spin 1.2s linear infinite;
  box-shadow: 0 0 30px rgba(245, 201, 107, .3);
}
.portal span:nth-child(2) { inset: 25px; border-top-color: var(--cyan); border-bottom-color: var(--gold); animation-duration: .9s; animation-direction: reverse; }
.portal span:nth-child(3) { inset: 50px; border-top-color: var(--magenta); border-bottom-color: var(--cyan); animation-duration: .7s; }
.portal span:nth-child(4) { inset: 80px; background: radial-gradient(circle, #fff, var(--gold) 40%, transparent 70%); border: 0; animation: pulse 1s ease-in-out infinite; }
.intro.zoom .portal { animation: portalZoom 1s cubic-bezier(.7, 0, .3, 1) forwards; }
@keyframes portalZoom { to { transform: scale(14) rotate(180deg); opacity: 0; } }
.intro-text { position: absolute; bottom: 22%; color: var(--gold-2); letter-spacing: .1em; animation: pulse 1.4s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .5; transform: scale(.92); } }

/* ---------- แถบบน ---------- */
.topbar {
  position: relative; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px clamp(16px, 4vw, 48px);
}
.logo { font-family: "Charm", serif; font-size: 1.8rem; color: var(--gold-2); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo .dot { font-family: "Cinzel Decorative", serif; font-size: 1rem; color: var(--gold); }
.logo-eye { display: inline-block; animation: spin 12s linear infinite; text-shadow: 0 0 12px var(--gold); }
.top-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- ปุ่ม ---------- */
.btn-gold {
  position: relative; overflow: hidden;
  padding: 12px 26px; border-radius: 999px;
  background: linear-gradient(135deg, var(--gold-2), var(--gold) 45%, var(--gold-3));
  color: #2a1503; font-weight: 600;
  box-shadow: 0 0 0 1px rgba(255, 231, 168, .6) inset, 0 8px 30px rgba(245, 201, 107, .35);
  transition: transform .25s, box-shadow .25s;
}
.btn-gold::after {
  content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .8), transparent);
  transform: skewX(-20deg); animation: sheen 3s ease-in-out infinite;
}
@keyframes sheen { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.btn-gold:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 0 0 1px #fff inset, 0 12px 44px rgba(245, 201, 107, .6); }
.btn-gold.small { padding: 8px 18px; font-size: .95rem; }
.btn-gold.big { padding: 16px 38px; font-size: 1.15rem; }
.btn-gold.full { width: 100%; padding: 14px; font-size: 1.05rem; }
.btn-ghost {
  padding: 8px 18px; border-radius: 999px; color: var(--gold-2);
  border: 1px solid var(--line); background: rgba(20, 10, 50, .4);
  backdrop-filter: blur(8px); transition: background .25s, border-color .25s;
}
a.btn-gold { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.nav-link { color: var(--gold-2); text-decoration: none; padding: 8px 10px; font-size: .95rem; transition: color .2s, text-shadow .2s; }
.nav-link:hover, .nav-link[aria-current="page"] { color: #fff; text-shadow: 0 0 10px var(--gold); }
a.btn-ghost { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn-ghost:hover { background: rgba(245, 201, 107, .12); border-color: var(--gold); }
.btn-ghost.big { padding: 15px 30px; font-size: 1.05rem; }

/* ---------- ฮีโร่ ---------- */
.hero {
  position: relative; z-index: 5;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 16px 40px; text-align: center;
}
.hero-copy { opacity: 0; transform: translateY(-20px); transition: all 1.2s ease .2s; }
body.ready .hero-copy { opacity: 1; transform: none; }
.eyebrow { color: var(--muted); letter-spacing: .2em; font-size: .85rem; margin-top: 4px; }
.title { line-height: 1.25; margin: 4px 0 14px; }
.title-th {
  font-family: "Charm", serif; font-size: clamp(3.4rem, 11vw, 7rem);
  background: linear-gradient(90deg, var(--gold-3), var(--gold-2), #fff, var(--gold), var(--gold-3));
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 6s linear infinite;
  filter: drop-shadow(0 0 24px rgba(245, 201, 107, .45));
}
.title-dot { font-family: "Cinzel Decorative", serif; font-size: clamp(1.4rem, 4vw, 2.6rem); color: var(--gold); margin-left: 4px; }
@keyframes shimmer { to { background-position: 300% 0; } }
.subtitle { color: var(--muted); font-weight: 300; font-size: clamp(.85rem, 2.2vw, 1.05rem); }

/* ---------- ฉากลูกแก้ว ---------- */
.scene {
  position: relative; width: var(--size); height: var(--size);
  margin: 10px 0 0; perspective: 1100px; transform-style: preserve-3d;
  opacity: 0; transform: scale(.4) rotate(-90deg);
  transition: opacity 1.4s ease .3s, transform 1.6s cubic-bezier(.2, .9, .2, 1.1) .3s;
}
body.ready .scene { opacity: 1; transform: none; }

.zodiac { position: absolute; inset: 0; width: 100%; height: 100%; animation: spin 80s linear infinite; }
.zodiac.inner { inset: 14%; width: 72%; height: 72%; animation-duration: 50s; animation-direction: reverse; opacity: .6; }
.z-line { fill: none; stroke: var(--line); stroke-width: 1.2; }
.z-line.thin { stroke-width: .6; stroke-dasharray: 2 6; }
.z-tick { stroke: var(--line); stroke-width: 1; }
.z-glyphs { font-family: "Segoe UI Symbol", "Apple Symbols", "DejaVu Sans", sans-serif; fill: var(--gold); font-size: 22px; letter-spacing: 6px; filter: drop-shadow(0 0 6px rgba(245, 201, 107, .8)); }

/* ไพ่โคจร 3 มิติ */
.orbit {
  position: absolute; left: 50%; top: 50%; width: 0; height: 0;
  transform-style: preserve-3d;
  animation: orbit 22s linear infinite;
}
@keyframes orbit {
  from { transform: rotateX(-14deg) rotateY(0deg); }
  to { transform: rotateX(-14deg) rotateY(360deg); }
}
.card {
  --w: calc(var(--size) * .17);
  position: absolute; width: var(--w); height: calc(var(--w) * 1.62);
  left: calc(var(--w) / -2); top: calc(var(--w) * -0.81);
  transform-style: preserve-3d;
  transform: rotateY(var(--a)) translateZ(calc(var(--size) * .46));
}
.card-inner {
  position: absolute; inset: 0; transform-style: preserve-3d;
  animation: bob 4s ease-in-out infinite; animation-delay: var(--d);
  transition: transform .6s;
}
@keyframes bob { 50% { transform: translateY(-14px); } }
.face {
  position: absolute; inset: 0; border-radius: 10px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: 2px solid var(--gold);
  box-shadow: 0 0 18px rgba(245, 201, 107, .45), inset 0 0 0 3px rgba(20, 8, 50, .9), inset 0 0 0 4px var(--gold-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
}
.face.front {
  background: linear-gradient(160deg, #2c1670, #12063a 60%, #3a1060);
  color: var(--gold-2); gap: 4px; padding: 6px;
}
.face.front .sym { font-size: calc(var(--w) * .42); line-height: 1; filter: drop-shadow(0 0 8px var(--gold)); }
.face.front .num { font-family: "Cinzel Decorative", serif; font-size: calc(var(--w) * .1); color: var(--gold); }
.face.front .name { font-family: "Cinzel Decorative", serif; font-size: calc(var(--w) * .085); letter-spacing: .05em; text-align: center; }
.face.back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 50%, transparent 22%, rgba(245, 201, 107, .5) 23%, transparent 25%),
    repeating-conic-gradient(from 0deg, rgba(245, 201, 107, .18) 0 10deg, transparent 10deg 20deg),
    linear-gradient(160deg, #3a1060, #0f0530);
  color: var(--gold);
}
.face.back::before { content: "☾✦☽"; font-size: calc(var(--w) * .2); text-shadow: 0 0 10px var(--gold); }

/* ลูกแก้ว */
.ball-wrap {
  position: absolute; left: 50%; top: 50%;
  width: 46%; aspect-ratio: 1; transform: translate(-50%, -56%);
  transform-style: preserve-3d;
}
.ball-glow {
  position: absolute; inset: -40%; border-radius: 50%;
  background: radial-gradient(circle, rgba(140, 90, 255, .55), rgba(209, 77, 255, .2) 40%, transparent 65%);
  animation: glow 3s ease-in-out infinite; pointer-events: none;
}
@keyframes glow { 50% { transform: scale(1.12); opacity: .7; } }
.ball {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .55), rgba(170, 140, 255, .35) 18%, rgba(70, 30, 160, .75) 55%, rgba(15, 5, 50, .95) 80%);
  box-shadow: 0 0 60px rgba(150, 100, 255, .8), 0 0 140px rgba(209, 77, 255, .4), inset 0 -20px 50px rgba(0, 0, 0, .6), inset 0 10px 40px rgba(255, 255, 255, .15);
  cursor: pointer; transition: transform .4s;
}
.ball:hover { transform: scale(1.04); }
.mist { position: absolute; inset: -30%; border-radius: 50%; mix-blend-mode: screen; filter: blur(14px); }
.m1 { background: conic-gradient(from 0deg, transparent, rgba(94, 231, 255, .55), transparent 40%, rgba(209, 77, 255, .6), transparent 75%); animation: spin 7s linear infinite; }
.m2 { background: conic-gradient(from 90deg, transparent, rgba(245, 201, 107, .45), transparent 35%, rgba(123, 77, 255, .7), transparent); animation: spin 11s linear infinite reverse; }
.m3 { inset: 10%; background: radial-gradient(circle at 60% 60%, rgba(255, 255, 255, .5), transparent 45%); animation: wander 6s ease-in-out infinite alternate; }
@keyframes wander { 0% { transform: translate(-15%, 10%) scale(.8); } 100% { transform: translate(15%, -10%) scale(1.2); } }
.ball-eye {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: calc(var(--size) * .1); color: #fff;
  text-shadow: 0 0 20px #fff, 0 0 40px var(--gold), 0 0 80px var(--magenta);
  animation: pulse 2.4s ease-in-out infinite;
}
.shine { position: absolute; top: 10%; left: 18%; width: 30%; height: 18%; border-radius: 50%; background: radial-gradient(ellipse, rgba(255, 255, 255, .85), transparent 70%); transform: rotate(-30deg); filter: blur(2px); }
.ball.flash { animation: flash .8s ease; }
@keyframes flash { 30% { filter: brightness(2.2) saturate(1.6); transform: scale(1.08); } }

.stand { position: absolute; left: 50%; top: 88%; transform: translateX(-50%); width: 70%; z-index: -1; }
.stand-top { height: calc(var(--size) * .05); margin: 0 12%; border-radius: 50% 50% 8px 8px / 30% 30% 8px 8px; background: linear-gradient(180deg, var(--gold-2), var(--gold) 40%, var(--gold-3)); box-shadow: 0 0 20px rgba(245, 201, 107, .5); }
.stand-base { height: calc(var(--size) * .045); border-radius: 0 0 50% 50% / 0 0 100% 100%; background: linear-gradient(180deg, var(--gold-3), #5a3a10); box-shadow: 0 10px 30px rgba(0, 0, 0, .6); }

/* ---------- CTA ---------- */
.cta {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
  margin-top: 18px;
  opacity: 0; transform: translateY(20px); transition: all 1s ease 1.2s;
}
body.ready .cta { opacity: 1; transform: none; }
.cta-sub { margin-top: 6px; gap: 6px 18px; }
.cta-sub .nav-link { display: inline-block; }

/* ---------- Marquee ---------- */
.marquee {
  position: relative; z-index: 5; overflow: hidden;
  border-block: 1px solid var(--line);
  background: rgba(15, 6, 40, .55); backdrop-filter: blur(6px);
  padding: 14px 0;
}
.marquee-track { display: flex; gap: 40px; width: max-content; animation: marquee 40s linear infinite; }
.marquee-track a { white-space: nowrap; color: var(--gold-2); font-size: 1.05rem; text-decoration: none; transition: color .2s, text-shadow .2s; }
.marquee-track a:hover { color: #fff; text-shadow: 0 0 10px var(--gold); }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-track a::before { content: "✦"; margin-right: 12px; color: var(--magenta); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Dialog ---------- */
.auth {
  margin: auto; width: min(440px, calc(100% - 32px)); max-height: calc(100% - 32px);
  padding: 28px 26px 24px; border-radius: 22px; color: var(--text);
  background: linear-gradient(170deg, rgba(40, 20, 95, .92), rgba(12, 5, 35, .96));
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(255, 231, 168, .08) inset, 0 30px 90px rgba(0, 0, 0, .7), 0 0 80px rgba(123, 77, 255, .35);
  overflow-y: auto;
}
.auth[open] { animation: popIn .5s cubic-bezier(.2, .9, .3, 1.2); }
.auth::backdrop { background: rgba(5, 2, 20, .7); backdrop-filter: blur(6px); }
@keyframes popIn { from { opacity: 0; transform: scale(.8) rotateX(20deg); } }
.close { position: absolute; top: 14px; right: 16px; width: 34px; height: 34px; border-radius: 50%; color: var(--muted); }
.close:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.auth-head { text-align: center; margin-bottom: 16px; }
.auth-moon { font-size: 2.4rem; color: var(--gold); text-shadow: 0 0 20px var(--gold); animation: pulse 3s ease-in-out infinite; }
.auth-head h2 { font-family: "Charm", serif; font-size: 2rem; color: var(--gold-2); }
.auth-head p { color: var(--muted); font-size: .9rem; }

.tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; background: rgba(0, 0, 0, .3); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.tab { position: relative; z-index: 1; padding: 9px; border-radius: 999px; color: var(--muted); transition: color .3s; }
.tab.active { color: #2a1503; font-weight: 600; }
.tab-ink { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px; background: linear-gradient(135deg, var(--gold-2), var(--gold)); transition: transform .35s cubic-bezier(.3, .9, .3, 1.1); }
.tabs[data-active="register"] .tab-ink { transform: translateX(100%); }
/* หน้าแอปหลัก: “สมัครบัญชี” อยู่ปุ่มแรก (ซ้าย) · “เข้าสู่ระบบ” อยู่ขวา */
#sheet .tabs .tab-ink { transform: translateX(100%); }
#sheet .tabs[data-active="register"] .tab-ink { transform: none; }

.form { display: flex; flex-direction: column; gap: 12px; }
.form[hidden] { display: none; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; color: var(--muted); }
.form small { font-size: .75rem; opacity: .7; }
.form input:not([type="checkbox"]) {
  font: inherit; color: var(--text); padding: 11px 14px; border-radius: 12px;
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(245, 201, 107, .2);
  outline: none; transition: border-color .25s, box-shadow .25s; color-scheme: dark;
}
.form input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 201, 107, .18); }
.form input:user-invalid { border-color: #ff6b8a; }
.form .check { flex-direction: row; align-items: center; gap: 8px; }
.form .check input { accent-color: var(--gold); width: 16px; height: 16px; }
.row { display: flex; justify-content: space-between; align-items: center; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.link { color: var(--gold); font-size: .9rem; text-decoration: none; }
.link:hover { text-decoration: underline; }

.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; color: var(--muted); font-size: .8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.socials { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.social { padding: 10px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .05); font-size: .9rem; transition: background .25s; }
.social:hover { background: rgba(255, 255, 255, .12); }
.social.line { color: #3ee07a; font-weight: 600; }

/* ---------- หน้าย่อย ---------- */
.page { position: relative; z-index: 5; max-width: 1080px; margin: 0 auto; padding: 0 16px 60px; text-align: center; }
.page-head { margin-bottom: 26px; animation: rise .9s ease both; }
.page-title {
  font-family: "Charm", serif; font-size: clamp(2.8rem, 9vw, 5rem); line-height: 1.3;
  background: linear-gradient(90deg, var(--gold-3), var(--gold-2), #fff, var(--gold), var(--gold-3));
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 6s linear infinite;
  filter: drop-shadow(0 0 20px rgba(245, 201, 107, .4));
}
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* ---------- Toast / effects ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 200;
  transform: translate(-50%, 40px); opacity: 0;
  padding: 12px 22px; border-radius: 999px;
  background: rgba(30, 15, 70, .95); border: 1px solid var(--gold); color: var(--gold-2);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5); transition: all .4s; pointer-events: none;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.spark {
  position: fixed; z-index: 150; pointer-events: none;
  width: 6px; height: 6px; border-radius: 50%;
  background: radial-gradient(circle, #fff, var(--gold) 50%, transparent 70%);
  animation: sparkFly var(--t, .9s) ease-out forwards;
}
@keyframes sparkFly { to { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  :root { --size: min(92vw, 420px); }
  .nav-tarot { display: none; }
  .nav-link { padding: 6px 4px; font-size: .82rem; }
  .top-actions { gap: 6px; }
  .topbar { padding: 14px 16px; }
  .logo { font-size: 1.4rem; }
  .btn-ghost { padding: 7px 12px; font-size: .85rem; }
  .btn-gold.small { padding: 7px 12px; font-size: .85rem; }
  .eyebrow { letter-spacing: .08em; font-size: .75rem; }
  .cta { flex-direction: column; width: 100%; }
  .cta button { width: 100%; }
  .two { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- โหมดแสดงในโทรศัพท์ (iframe) ---------- */
.embedded .topbar { display: none; }
.embedded body { padding-top: 14px; }
.embedded .page-head { margin-bottom: 18px; }
.embedded, .embedded body { scrollbar-width: none; }
.embedded ::-webkit-scrollbar { display: none; }

/* ---------- อ่านง่าย: หัวข้อฟอนต์ Charm มีสระบน/ล่างสูง ต้องเว้นบรรทัดพอ และไม่ถ่างตัวอักษรไทย ---------- */
.eyebrow { letter-spacing: .08em; }
.page-title { line-height: 1.5; padding: .1em 0 .05em; }
.auth-head h2 { line-height: 1.5; padding-top: .1em; }

/* ---------- ฟอนต์ Charm: สระบน/วรรณยุกต์สูงมาก → เว้นบรรทัดและระยะด้านบนให้พอ ---------- */
.page-head .eyebrow { margin-bottom: .35em; }
.page-title { line-height: 1.75; padding-top: .15em; margin: 0; }
.auth-head h2 { line-height: 1.65; padding-top: .15em; }
.logo, .app-logo { line-height: 1.6; }
/* หัวข้อเล็กที่อยู่เหนือหัวข้อ Charm ทุกหน้า (page-head / tarot-head / อื่น ๆ) */
.eyebrow + .page-title { margin-top: .12em; padding-top: .2em; }
/* หัวข้อไล่สีทอง (background-clip: text) วาดสีได้เฉพาะในกรอบของตัวเอง —
   หางของ ไ / โ และวรรณยุกต์ใน Charm สูงเกินกรอบ จึงต้องขยายกรอบขึ้นไปให้คลุมทั้งตัวอักษร */
.page-title, .eyebrow + .page-title { padding: .5em .3em .25em; margin-top: -.15em; line-height: 1.4; }
.eyebrow + .page-title { margin-top: .2em; }
.page-title + .subtitle { margin-top: .35em; }

/* ============ มือถือ (iOS/Android): ฟอร์มลื่นขึ้น ============ */
html { -webkit-text-size-adjust: 100%; }
a, button, label, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* ช่องวันที่/เวลาของ iOS มีความกว้างในตัว ทำให้ล้นกรอบ → บังคับเต็มช่องและสูงเท่าช่องอื่น */
.form input[type="date"], .form input[type="time"] {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; min-width: 0; min-height: 46px; line-height: 1.4; text-align: left; }
.form input::-webkit-date-and-time-value { text-align: left; min-height: 1.4em; }
.form input::-webkit-datetime-edit { padding: 0; }
/* กล่องยอมรับเงื่อนไข: ช่องติ๊กชิดซ้ายกับข้อความ */
.form .check { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; text-align: left; line-height: 1.5; }
.form .check input[type="checkbox"] { flex: none; width: 20px !important; height: 20px; min-width: 20px; margin: 0; }
@media (max-width: 700px) {
  /* ตัวอักษรในช่องกรอก ≥ 16px ไม่ให้ iPhone ซูมหน้าจอเองตอนแตะ */
  .form input:not([type="checkbox"]), .form select, .form textarea, .ai-input textarea { font-size: 16px; }
}

/* ---------- ช่องยอมรับเอกสารตอนสมัคร + ป๊อปอัปรายละเอียด ---------- */
.consents { display: grid; gap: 8px; padding: 12px; border-radius: 14px; border: 1px solid rgba(245, 201, 107, .22); background: rgba(30, 16, 70, .45); }
.consents .check { flex-wrap: wrap; color: var(--text); font-size: .88rem; }
.consents .check b { font-weight: 500; color: var(--gold-2); }
.consents .check span { flex: 1 1 0; min-width: 0; }
.consent-read { flex: none; font-size: .8rem; color: var(--gold-2); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; padding: 4px 0; }
.policy-dialog {
  width: min(720px, calc(100vw - 24px)); height: min(86vh, 900px); max-width: none; max-height: none;
  margin: auto; padding: 0; border: 1px solid rgba(245, 201, 107, .35); border-radius: 20px;
  background: var(--bg); color: var(--text); overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.policy-dialog[open] { display: flex; flex-direction: column; }
.policy-dialog::backdrop { background: rgba(4, 2, 14, .72); backdrop-filter: blur(4px); }
.policy-dialog header, .policy-dialog footer { display: flex; align-items: center; gap: 10px; padding: 12px 16px; flex: none; background: rgba(30, 16, 70, .7); }
.policy-dialog header { justify-content: space-between; border-bottom: 1px solid rgba(245, 201, 107, .18); }
.policy-dialog h2 { font-size: 1.05rem; font-weight: 500; color: var(--gold-2); }
.policy-x { width: 34px; height: 34px; border-radius: 50%; color: var(--muted); }
.policy-x:hover { color: var(--gold-2); background: rgba(245, 201, 107, .1); }
.policy-dialog iframe { flex: 1; width: 100%; border: 0; background: var(--bg); }
.policy-dialog footer { justify-content: flex-end; border-top: 1px solid rgba(245, 201, 107, .18); }
.policy-dialog footer .btn-gold, .policy-dialog footer .btn-ghost { width: auto; padding: 10px 18px; }
@media (max-width: 560px) {
  .policy-dialog { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .policy-dialog footer > * { flex: 1; }
}

/* ซ่อนปุ่มเข้าสู่ระบบด้วยโซเชียลจนกว่าจะเชื่อมต่อจริง */
.divider[hidden], .socials[hidden] { display: none; }

/* ===== ไอคอนเส้น (icons.js แทนที่อีโมจิ) ===== */
.ic { width: .95em; height: .95em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.14em; }
.ic-inline { margin-right: .4em; }
.pick-ico, .cat-ico, .mk-ico, .ms-ico, .mk-ci, .pl-ico, .mk-pi, .ff-ico, .ci, .svc-icon, .fb-icon, .wc-flag, .es-ico, .type-ico { color: var(--gold-2); }

/* ธงชาติ (icons.js แทนอีโมจิธงด้วยรูป SVG) */
.flag { height: .85em; width: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .2); vertical-align: -.12em; margin-right: .35em; }
.flag:last-child { margin-right: 0; }
.wc-flag .flag, .wc-bg .flag { width: 1em; height: 1em; aspect-ratio: 1; border-radius: 50%; margin: 0; box-shadow: none; }
/* ธงจีน: ธงสี่เหลี่ยมถูกตัดเป็นวงกลมแล้วดาวมุมซ้ายบนหาย → แสดงทั้งผืนแล้วเติมพื้นแดงเต็มวง */
.flag[src$="/cn.svg"] { object-fit: contain; background: #de2910; }
.lf .flag { height: 1em; margin: 0; }

/* ภาพประจำภูมิภาคที่ไม่ใช่ธงประเทศเดียว: ทิเบต (ภาพวาดสีสัน) · โลกอาหรับและเปอร์เซีย (ธง 2 ผืนครึ่งวงกลม) */
.region-art { width: 1em; height: 1em; border-radius: 50%; object-fit: cover; vertical-align: -.14em; margin-right: .3em; }
.flag-split { display: inline-flex; width: 1em; height: 1em; border-radius: 50%; overflow: hidden; vertical-align: -.14em; margin-right: .3em; box-shadow: 0 0 0 1px rgba(0, 0, 0, .2); }
.flag-split img { width: 50%; height: 100%; object-fit: cover; }
.wc-flag .region-art, .wc-flag .flag-split, .wc-bg .region-art, .wc-bg .flag-split, .svc-icon .region-art, .svc-icon .flag-split { margin: 0; }
.wc-flag .region-art, .wc-flag .flag-split { width: 1em; height: 1em; }
