/* ==========================================================================
   ปุ่มสลับกลางวัน/กลางคืน — ต้นแบบ "Interactive Toggle Button"
   ทุกขนาดอิงความกว้าง --tg-w (ปุ่มเล็กบนแถบบน · ปุ่มใหญ่พร้อมเงาสะท้อนในหน้า login)
   สถานะกลางคืน = .tg.night (app.js ใส่ตาม <html data-theme>)
   ========================================================================== */
.tg-wrap { display: inline-flex; flex-direction: column; align-items: center; }
.tg {
  position: relative; display: block; flex: none;
  width: var(--tg-w, 84px); aspect-ratio: 300 / 96; padding: 0;
  border: 0; border-radius: 999px; cursor: pointer; outline: none; background: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .35) inset, 0 6px 16px rgba(30, 58, 43, .28);
}
.tg:focus-visible { box-shadow: 0 0 0 3px var(--lime), 0 6px 16px rgba(30, 58, 43, .28); }
.tg-track {
  position: absolute; inset: 0; overflow: hidden; border-radius: inherit;
  background: linear-gradient(100deg, #a9d3e8 0%, #5e9fd6 100%);
  transition: background 1.1s ease;
}
.tg.night .tg-track { background: linear-gradient(100deg, #12123f 0%, #2c2f60 100%); }
.tg-track::after {   /* แสงเงาบนผิวปุ่ม */
  content: ""; position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0) 40%);
}

/* ดาว (สุ่มตำแหน่งใน app.js) */
.tg-stars { position: absolute; inset: 0; z-index: 1; opacity: 0; transition: opacity 1s ease; }
.tg.night .tg-stars { opacity: 1; }
.tg-stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; animation: tgTwinkle 3s ease-in-out infinite; }

/* ดาวตก */
.tg-shoots { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity 1s ease; }
.tg.night .tg-shoots { opacity: 1; }
.tg-shoots i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; opacity: 0;
  box-shadow: 0 0 4px rgba(255, 255, 255, .9); transform: rotate(-32deg); animation: tgShoot 3.5s linear infinite; }
.tg-shoots i::before { content: ""; position: absolute; top: 50%; right: 0; width: calc(var(--tg-w, 84px) * .17); height: 1px; transform: translateY(-50%);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .85)); }
.tg-shoots .s1 { top: 25%; left: 72%; }
.tg-shoots .s2 { top: 48%; left: 48%; animation-delay: -1.7s; }
.tg-shoots .s3 { top: 18%; left: 30%; animation-delay: -2.8s; }

/* พระจันทร์ · ดวงอาทิตย์ */
.tg-moon { position: absolute; left: 10%; top: 50%; z-index: 2; width: 19%; height: auto; transform: translateY(-50%) rotate(-18deg);
  opacity: .3; filter: drop-shadow(0 0 3px rgba(255, 244, 200, .6)); transition: opacity .45s ease; }
.tg.night .tg-moon { opacity: 1; }
.tg-sun { position: absolute; right: 12%; top: 50%; z-index: 2; width: 13%; aspect-ratio: 1; border-radius: 50%; transform: translateY(-50%);
  background: radial-gradient(circle at 35% 30%, #fff6c8, #ffe98a 60%, #f7d55c 100%);
  box-shadow: 0 0 calc(var(--tg-w, 84px) * .045) calc(var(--tg-w, 84px) * .012) rgba(255, 233, 138, .8); transition: opacity .8s ease; }
.tg.night .tg-sun { opacity: 0; }

/* นกบิน */
.tg-birds { position: absolute; top: 24%; left: 0; z-index: 2; width: 100%; height: 22%; opacity: .9; transition: opacity .8s ease; }
.tg.night .tg-birds { opacity: 0; }
.tg-bird { position: absolute; top: 0; width: 5.3%; height: auto; animation: tgFly 7s linear infinite; }
.tg-bird .tg-wing { transform-origin: 7px 6px; animation: tgFlap .5s ease-in-out infinite; }
.tg-bird.b2 { top: 35%; animation-delay: -2.3s; }
.tg-bird.b2 .tg-wing { animation-delay: -.18s; }
.tg-bird.b3 { top: 8%; animation-delay: -4.6s; }
.tg-bird.b3 .tg-wing { animation-delay: -.32s; }

/* เมฆเลื่อน */
.tg-clouds { position: absolute; left: 0; right: 0; bottom: -4%; z-index: 3; height: 48%; overflow: hidden; pointer-events: none; transition: opacity 1s ease; }
.tg.night .tg-clouds { opacity: .55; filter: brightness(.55) saturate(.7); }
.tg-cloud-track { position: absolute; left: 0; bottom: 0; display: flex; flex-wrap: nowrap; width: 100%; height: 100%; animation: tgCloud 16s linear infinite; }
.tg-cloud-track img { flex: 0 0 50%; width: 55%; height: 100%; margin: 0 -2.5%; object-fit: contain; object-position: center bottom;
  transform: scale(1.12); pointer-events: none; user-select: none; -webkit-user-drag: none; }

/* ปุ่มกลม */
.tg-knob { position: absolute; top: 8%; left: 2.5%; z-index: 6; width: 27%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff, #fdfdfd 55%, #f4f4f4 100%);
  box-shadow: 0 0 calc(var(--tg-w, 84px) * .06) calc(var(--tg-w, 84px) * .02) rgba(255, 255, 255, .05),
              0 0 calc(var(--tg-w, 84px) * .08) calc(var(--tg-w, 84px) * .03) rgba(255, 244, 190, .55);
  transition: left .65s cubic-bezier(.65, -.1, .25, 1.15), box-shadow 1.1s ease; }
.tg.night .tg-knob { left: 70.5%;
  box-shadow: 0 0 calc(var(--tg-w, 84px) * .056) calc(var(--tg-w, 84px) * .02) rgba(255, 255, 255, .9),
              0 0 calc(var(--tg-w, 84px) * .15) calc(var(--tg-w, 84px) * .05) rgba(160, 190, 255, .55); }
@media (hover: hover) { .tg:hover .tg-knob { transform: scale(1.04); } }

/* เงาสะท้อน (เฉพาะปุ่มใหญ่) */
.tg-reflect { margin-top: 3px; pointer-events: none; transform: scaleY(-1); filter: blur(2px); opacity: .3; box-shadow: none;
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, .85), rgba(0, 0, 0, 0) 75%);
  mask-image: linear-gradient(to top, rgba(0, 0, 0, .85), rgba(0, 0, 0, 0) 75%); }

@keyframes tgTwinkle { 0%, 100% { opacity: .15; } 50% { opacity: .9; } }
@keyframes tgShoot { 0% { opacity: 0; transform: rotate(-32deg) translateX(0); } 5% { opacity: 1; }
  18% { opacity: 0; transform: rotate(-32deg) translateX(calc(var(--tg-w, 84px) * -.25)); } 100% { opacity: 0; transform: rotate(-32deg) translateX(calc(var(--tg-w, 84px) * -.25)); } }
@keyframes tgFly { from { left: 75%; } to { left: -15%; } }
@keyframes tgFlap { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.35); } }
@keyframes tgCloud { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .tg *, .tg { animation: none !important; transition: none !important; }
}
