/* ตัวแปรสี */
:root {
    --purple: #6E4DC1;
    --pink: #C56ED2;
    --bg: #050831;
    --surface: #0B1342;
    --surface2: #111B4F;
    --line: #26306B;
    --text: #E8EAF6;
    --muted: #A9B0D6;
    --ok: #34D399;
    --warn: #FBBF24;
    --err: #FB7185;
    --container: 1280px;
    --gutter: 16px;
    --gutter-lg: 32px;
    --radius: 12px;
}

/* กฎ hidden ของเบราว์เซอร์ ([hidden] { display: none }) เป็นกฎ user-agent
   แพ้กฎของเราทุกตัวที่ตั้ง display เช่น .hint { display: block }
   ผลคือ <div class="hint" hidden> โผล่ค้าง และ el.hidden = true ไม่มีผล
   เคยโดนกับกล่อง "คัดลอกแล้ว" ในหน้าบัญชี — บรรทัดนี้กันทุกกรณีในอนาคตด้วย */
[hidden] {
    display: none !important;
}

/* รีเซ็ตและฐาน */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* แถบบนสุด */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    white-space: nowrap;
}

.logo-baby {
    color: var(--purple);
}

.logo-live {
    color: var(--pink);
}

.nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
}

.nav::-webkit-scrollbar {
    display: none;
}

.nav a,
.nav-logout {
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--muted);
    white-space: nowrap;
    font-size: 15px;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.nav a:hover,
.nav-logout:hover {
    color: var(--text);
    background: var(--surface2);
}

.nav-signup {
    color: var(--pink) !important;
    font-weight: 600;
}

/* แถบแจ้งเตือน */
.flash-container {
    max-width: var(--container);
    margin: 16px auto 0;
    padding: 0 16px;
}

.flash {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    font-size: 15px;
}

.flash-success {
    background: rgba(52, 211, 153, 0.15);
    color: var(--ok);
    border: 1px solid var(--ok);
}

.flash-error {
    background: rgba(251, 113, 133, 0.15);
    color: var(--err);
    border: 1px solid var(--err);
}

.flash-info {
    background: rgba(110, 77, 193, 0.15);
    color: var(--purple);
    border: 1px solid var(--purple);
}

/* เนื้อหาหลัก */
.wrap {
    max-width: var(--container);
    margin: 0 auto;
    padding: 16px;
    flex: 1;
}

main {
    padding-top: 24px;
    padding-bottom: 32px;
}

/* ปุ่ม */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 26px;
    min-height: 44px;
    border-radius: var(--radius);
    border: none;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    line-height: 1.2;
    transition: transform .18s, box-shadow .18s, background .18s, border-color .18s;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--purple), var(--pink));
    color: white;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(110,77,193,0.30);
}

.btn-ghost {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--line);
}

.btn-block {
    display: flex;
    width: 100%;
}

/* การ์ด */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

/* ฟอร์ม */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    background: var(--surface2);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    transition: border-color 0.2s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--purple);
}

.field textarea {
    min-height: 88px;
    resize: vertical;
}

.hint {
    display: block;
    margin-top: 4px;
    font-size: 14px;
    color: var(--muted);
}

.err-text {
    display: block;
    margin-top: 4px;
    font-size: 14px;
    color: var(--err);
}

/* ป้ายสถานะ */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}

.badge-ok {
    background: rgba(52, 211, 153, 0.15);
    color: var(--ok);
}

.badge-warn {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warn);
}

.badge-err {
    background: rgba(251, 113, 133, 0.15);
    color: var(--err);
}

/* กริด */
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 640px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1024px) {
    .grid {
        gap: 24px;
    }
    
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1400px) {
    .grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

.grid-duo {
    max-width: 940px;
    margin-left: auto;
    margin-right: auto;
}

/* รหัสไลเซนส์ */
.license-key {
    font-family: "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 18px;
    letter-spacing: 0.5px;
    background: var(--surface2);
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--line);
    width: 100%;
    color: var(--text);
    user-select: all;
}

/* แถวอุปกรณ์ */
.device-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.device-row:last-child {
    border-bottom: none;
}

/* ตัวอักษรจาง */
.muted {
    color: var(--muted);
}

/* จัดกลาง */
.center {
    text-align: center;
}

/* เรียงแนวตั้ง */
.stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ฟุตเตอร์ */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--line);
    margin-top: auto;
}

.footer-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 24px 16px;
    text-align: center;
}

.footer-links {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin: 12px 0;
}

.footer-links a {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
}

.footer-links a:hover {
    color: var(--text);
}

.footer p {
    font-size: 14px;
}

/* โฟกัสที่มองเห็นชัด */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--purple);
    outline-offset: 2px;
}

/* ปิดแอนิเมชันสำหรับคนที่ตั้งค่าลดการเคลื่อนไหว */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* ===== โลโก้ หน้าต่างเด้ง และป้ายบอกแพลตฟอร์ม ===== */
/* โลโก้และแบรนด์ */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.nav-form {
  display: inline;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.footer-brand img {
  border-radius: 6px;
}

/* ป้ายบอกแพลตฟอร์ม */
.platform-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 14px;
}

.platform-note strong {
  color: var(--text);
}

.platform-badge {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

/* หน้าต่างเด้ง */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 49, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: modalIn 0.18s ease-out;
}

.modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--purple), var(--pink));
  border-radius: 20px 20px 0 0;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s;
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface2);
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.modal-head img {
  border-radius: 12px;
}

.modal-head h2 {
  font-size: 20px;
  margin: 0;
}

.modal-note {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.modal-or {
  display: flex;
  align-items: center;
  margin: 18px 0;
}

.modal-or::before,
.modal-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.modal-or span {
  color: var(--muted);
  font-size: 12px;
  padding: 0 12px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  margin-top: 16px;
}

.modal-foot a {
  color: var(--pink);
  text-decoration: none;
}

.modal-foot a:hover {
  text-decoration: underline;
}

body.modal-open {
  overflow: hidden;
}

/* แอนิเมชัน */
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal {
    animation: none;
  }
}

/* มือถือ */
@media (max-width: 640px) {
  .logo-mark {
    width: 30px;
    height: 30px;
  }

  .modal {
    padding: 22px 18px;
    border-radius: 16px;
  }

  .modal::before {
    border-radius: 16px 16px 0 0;
  }
}

/* แก้โลโก้ตัดบรรทัดและเมนูล้นขอบบนมือถือ */
.logo-text {
    white-space: nowrap;      /* ห้าม "Baby" กับ "Live" หลุดคนละบรรทัด */
    line-height: 1;
}
.header-inner {
    gap: 12px;
}
@media (max-width: 600px) {
    /* จอแคบ: ย่อโลโก้ลงเพื่อเหลือที่ให้เมนู */
    .logo-mark { width: 28px; height: 28px; }
    .logo-text { font-size: 17px; }
    .nav { gap: 12px; }
    .nav a, .nav-logout { font-size: 14px; }
}

/* .logo-text ถูกตั้งเป็น flex column ทำให้ "Baby" กับ "Live" เรียงลงมาคนละบรรทัด
   บังคับให้เรียงแนวนอนเป็นคำเดียว */
.logo-text {
    display: inline-flex;
    flex-direction: row;
    align-items: baseline;
}

/* ส่วนเพิ่มเติมสำหรับ responsive และ components ใหม่ */
@media (min-width: 1024px) {
    .header-inner, .flash-container, .wrap, .footer-inner {
        padding-left: var(--gutter-lg);
        padding-right: var(--gutter-lg);
    }
}

@media (min-width: 1600px) {
    .header-inner, .flash-container, .wrap, .footer-inner {
        padding-left: 48px;
        padding-right: 48px;
    }
}

.btn-primary:hover {
    box-shadow: 0 10px 26px rgba(197,110,210,0.42);
}

.btn-ghost:hover {
    background: var(--surface);
    border-color: var(--purple);
    color: var(--text);
}

.btn-lg {
    padding: 16px 34px;
    font-size: 17px;
    min-height: 52px;
}

.btn:disabled, .btn[disabled] {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.hero {
    position: relative;
    padding: 56px 24px 48px;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: radial-gradient(1100px 420px at 50% -30%, rgba(197,110,210,0.20), transparent 70%), radial-gradient(800px 360px at 12% 110%, rgba(110,77,193,0.18), transparent 70%), var(--surface);
    overflow: hidden;
    margin-bottom: 28px;
}

.hero h1 {
    font-size: clamp(28px, 5vw, 52px);
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-bottom: 14px;
}

.hero > p {
    font-size: clamp(16px, 1.6vw, 20px);
    max-width: 62ch;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 1024px) {
    .hero {
        padding: 88px 48px 72px;
    }
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 28px;
}

@media (min-width: 640px) {
    .hero-actions {
        gap: 16px;
    }
}

.hero-actions .btn {
    min-width: 200px;
}

@media (max-width: 480px) {
    .hero-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .hero-actions .btn {
        min-width: 0;
        width: 100%;
    }
}

.platform-badge {
    margin-top: 20px;
}

.cta-band {
    text-align: center;
    padding: 48px 24px;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: radial-gradient(900px 380px at 50% 120%, rgba(110,77,193,0.22), transparent 70%), var(--surface);
    margin-top: 32px;
}

.cta-band h2 {
    font-size: clamp(22px, 3vw, 34px);
    margin-bottom: 10px;
}

.cta-band .hero-actions {
    margin-top: 22px;
}

/* ปุ่ม Google — สีขาวและโลโก้ G เป็นข้อบังคับของ Google ห้ามเปลี่ยนเป็นสีของเว็บ */
.btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 16px;
    background: #FFFFFF;
    color: #3C4043;
    border: 1px solid #DADCE0;
    border-radius: 4px;
    font-family: Roboto, "Helvetica Neue", system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.15px;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, box-shadow .15s, border-color .15s;
}

.btn-google svg, .btn-google img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: block;
}

.btn-google:hover {
    background: #F8F9FA;
    border-color: #D2E3FC;
    box-shadow: 0 1px 2px rgba(60,64,67,.30), 0 1px 3px 1px rgba(60,64,67,.15);
}

.btn-google:active {
    background: #ECEFF1;
    box-shadow: 0 1px 2px rgba(60,64,67,.30);
}

.btn-google:focus-visible {
    outline: 2px solid #4285F4;
    outline-offset: 2px;
}

.btn-google-block {
    display: flex;
    width: 100%;
}

.wrap > .center > .card {
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

.help-step {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
}

.help-step h2 {
    font-size: 19px;
    margin-bottom: 6px;
}

.help-step p {
    color: var(--muted);
}

.card ul, .card ol {
    padding-left: 20px;
    margin-top: 8px;
}

.card li {
    margin-bottom: 6px;
}

.card h3 {
    margin-bottom: 8px;
}

.card > svg {
    margin-bottom: 12px;
    color: var(--pink);
}

section + section {
    margin-top: 40px;
}

section > h2.center {
    margin-bottom: 20px;
}

h1, h2, h3 {
    line-height: 1.25;
}

.lede {
    max-width: 62ch;
    margin-left: auto;
    margin-right: auto;
}

@media (prefers-reduced-motion: reduce) {
    .btn:hover {
        transform: none;
    }
}


/* ===== หัวหน้าเพจ และการจัดการ์ดในกริดบนจอกว้าง ===== */

/* หัวเรื่องของหน้าราคา/วิธีใช้ — ไม่ใหญ่เท่าฮีโร่หน้าแรก แต่ยังมีที่หายใจ */
.page-head {
    text-align: center;
    padding: 32px 0 12px;
}

.page-head h1 {
    font-size: clamp(26px, 3.4vw, 42px);
    margin-bottom: 10px;
}

/* การ์ดที่อยู่ในกริด: ระยะห่างมาจาก gap ของกริดแล้ว ไม่ต้องมี margin ซ้อน
   และให้ทุกใบในแถวเดียวกันสูงเท่ากัน */
.grid > .card,
.grid > .help-step {
    margin-bottom: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.grid > .card > p:last-child,
.grid > .card > ul:last-child,
.grid > .help-step > p:last-child {
    margin-bottom: 0;
}

/* ปุ่มที่อยู่ล่างสุดของการ์ดราคา ให้ดันไปชิดขอบล่างเสมอ แถวจะได้เรียงตรงกัน */
.grid > .card > .btn:last-child {
    margin-top: auto;
}

/* กล่องข้อความยาว ๆ ไม่ควรกว้างตามจอ 2560px เพราะสายตากวาดไม่ไหว */
.license-setup .card,
.contact .card {
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
}

/* หน้าวิธีใช้: หัวข้อหลักมีที่หายใจเหมือนหน้าอื่น */
.help > h1 {
    font-size: clamp(26px, 3.4vw, 42px);
    padding: 32px 0 12px;
}

/* แถบบอกว่าโปรแกรมใช้บน Windows — บนจอกว้างให้อยู่กลางและไม่ยืดเต็ม */
.platform-note {
    display: flex;
    max-width: 860px;
    margin: 24px auto;
}

/* เมนูบนสุด: จอกว้างให้เมนูชิดขวา ถ่วงน้ำหนักกับโลโก้ทางซ้าย
   จอแคบยังเป็นแถวเลื่อนซ้ายขวาเหมือนเดิม ไม่แตะ */
@media (min-width: 1024px) {
    .nav {
        justify-content: flex-end;
        gap: 4px;
    }
}

/* ป้ายกำกับที่ไม่ได้ระบุสถานะ (ป้ายบนการ์ดราคา) ให้เห็นเป็นป้ายจริง ไม่ใช่ข้อความลอย
   ใช้ :not เพื่อไม่ให้ไปทับ .badge-ok / .badge-warn / .badge-err ที่มีสีของตัวเอง */
.badge:not([class*="badge-"]) {
    background: var(--surface2);
    border: 1px solid var(--line);
    color: var(--muted);
    margin-bottom: 10px;
}

/* จอกว้างมาก (2K/4K): ขยายกรอบเนื้อหาอีกขั้น จะได้ไม่กองอยู่แค่กลางจอ
   ย่อหน้ายาว ๆ ยังถูกคุมความกว้างด้วย .lede / max-width: 62ch อยู่ อ่านสบายเหมือนเดิม */
@media (min-width: 1800px) {
    :root {
        --container: 1480px;
    }

    .hero {
        padding: 104px 64px 88px;
    }
}

/* การ์ดในกริดถูกทำเป็น flex column เพื่อให้สูงเท่ากันทั้งแถว
   ผลข้างเคียงคือลูกที่ไม่ได้กำหนดความกว้างจะถูกยืดเต็มการ์ด
   ป้ายกำกับต้องกว้างตามข้อความเท่านั้น จึงต้องสั่งไม่ให้ยืด */
.grid > .card > .badge {
    align-self: flex-start;
}


/* เครื่องที่ผูกกับบัญชี — กฎ 1 บัญชี 1 เครื่อง (หน้าบัญชีและแผงแอดมิน)
   .device-row ของเดิมใช้ซ้ำได้ เติมแค่ flex-wrap กันปุ่มตกขอบบนจอแคบ */
.device-row { flex-wrap: wrap; gap: 12px; }
.device-id { font-family: 'SF Mono', 'Roboto Mono', monospace; font-size: .85rem; word-break: break-all; }
.device-seen { font-size: .8rem; margin-top: .25rem; }
.device-quota { margin-top: .75rem; }
