
/* 🌟 หน้าเริ่มต้นแบบไอจี — รวม start/login/signup ไว้ในวิวเดียว (view-start)
   switchView('view-login') / switchView('view-signup') ถูก map มาที่นี่ใน index.html แล้วเปิดแผงที่ตรงกัน
   ใช้คลาสขึ้นต้น .hqa- ทั้งหมด กันชนกับ CSS ของหน้าอื่นที่ถูก include อยู่ในไฟล์เดียวกัน
   (ห้ามตั้ง body/html ที่นี่ — ดูเหตุผลใน Safety CSS ท้าย index.html) 🌟 */
#view-start { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
.hqa-screen, .hqa-screen * { box-sizing: border-box; }

.hqa-screen {
  position: fixed; inset: 0; z-index: 10;
  background: #000; color: #f5f5f5;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; align-items: center;
  /* ด้านล่างเว้นที่ให้แคปซูลเมนูบาร์ของ hqux (ลอยทับอยู่ท้ายจอ) ไม่ให้บังปุ่มสร้างบัญชี/ตัวอักษร HQUX */
  padding: max(20px, env(safe-area-inset-top)) 20px calc(env(safe-area-inset-bottom) + 84px);
}
.hqa-main {
  flex: 1; width: 100%; max-width: 350px;
  display: flex; flex-direction: column; justify-content: center;
  padding: 40px 0 24px;
}
.hqa-back {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 10px;
  background: none; border: 0; color: #f5f5f5; font-size: 28px; padding: 6px; cursor: pointer;
  display: flex;
}
.hqa-back[hidden] { display: none; }
.hqa-foot-btn-hidden { display: none !important; }
[data-signup-cta][hidden] { display: none !important; }
/* ช่องดักบอท — คนมองไม่เห็น/กดไม่ถึง บอทกรอกฟอร์มอัตโนมัติมักใส่ค่าลงไป (ดู utils/signup_guard.py) */
.hqa-hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; opacity: 0; }

.hqa-logo { display: flex; justify-content: center; margin-bottom: 44px; }
.hqa-logo img { width: 76px; height: 76px; object-fit: contain; filter: brightness(0) invert(1); -webkit-user-drag: none; user-select: none; }

.hqa-panel { display: none; flex-direction: column; animation: hqa-in .28s ease; }
.hqa-panel.active { display: flex; }
.hqa-step { display: none; flex-direction: column; gap: 12px; animation: hqa-in .28s ease; }
.hqa-step.active { display: flex; }
@keyframes hqa-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hqa-title { text-align: center; font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.hqa-sub { text-align: center; font-size: 13px; line-height: 1.5; color: #8e8e8e; margin-bottom: 10px; }
.hqa-sub b { color: #f5f5f5; font-weight: 600; word-break: break-all; }

.hqa-field { position: relative; }
.hqa-input, .hqa-select {
  width: 100%; height: 50px; padding: 0 44px 0 16px;
  background: #0d0d0d; color: #f5f5f5; font-size: 15px; font-family: inherit;
  border: 1px solid #2e2e2e; border-radius: 0; outline: none; box-shadow: none;
  -webkit-appearance: none; appearance: none; transition: border-color .2s;
}
.hqa-input:focus, .hqa-select:focus { border-color: #8e8e8e; }
.hqa-input::placeholder { color: #6b6b6b; }
.hqa-select option { background: #121212; color: #fff; }
.hqa-row { display: flex; gap: 8px; }
.hqa-row .hqa-select { flex: 1 1 0; min-width: 0; padding: 0 8px; text-align: center; text-align-last: center; font-size: 14px; }

.hqa-icon-r {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 20px; color: #6b6b6b; cursor: pointer; display: flex;
}
.hqa-icon-r.ok { color: #f5f5f5; cursor: default; }
.hqa-icon-r.bad { color: #ed4956; cursor: default; }

.hqa-btn {
  height: 46px; width: 100%; border-radius: 0; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity .2s, transform .1s;
}
.hqa-btn:active { transform: scale(.98); }
.hqa-btn[disabled] { opacity: .45; pointer-events: none; }
.hqa-btn-primary { background: #f5f5f5; color: #000; border: 0; margin-top: 4px; }
.hqa-btn-ghost { background: transparent; color: #f5f5f5; border: 1px solid #2e2e2e; }

.hqa-link {
  background: none; border: 0; color: #f5f5f5; font-family: inherit; font-size: 14px;
  cursor: pointer; padding: 10px 0; text-align: center;
}
.hqa-link.muted { color: #8e8e8e; font-size: 13px; }
.hqa-link[disabled] { color: #555; pointer-events: none; }

.hqa-foot { width: 100%; max-width: 350px; display: flex; flex-direction: column; gap: 14px; }
.fp-found { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #cfcfcf; padding: 2px 4px; }
.fp-found[hidden] { display: none; }
.fp-found i { color: #4cd964; font-size: 18px; flex: none; }
.fp-found #fp-found-mail { color: #8a8a8a; }
#fp-send-btn[hidden], #fp-check-btn[hidden], #fp-other-btn[hidden] { display: none !important; }
.hqa-brand { text-align: center; font-size: 11px; letter-spacing: .25em; color: #555; font-weight: 700; }

/* ── ปุ่มย้อน/ถัดไปของขั้นตอนสมัคร (แบบเดิม) ── */
.hqa-nav { display: flex; justify-content: center; gap: 24px; margin-top: 8px; }
.hqa-nav button { background: none; border: 0; cursor: pointer; padding: 8px; display: flex; transition: transform .2s cubic-bezier(.175,.885,.32,1.275); }
.hqa-nav button:active { transform: scale(.8); }
.hqa-nav i { font-size: 26px; color: #fff; opacity: .8; }
.hqa-nav button:hover i { opacity: 1; }

/* ── OTP 6 ช่อง สี่เหลี่ยม มินิมอล ── */
.hqa-otp { display: flex; justify-content: center; gap: 8px; margin: 6px 0 2px; }
.hqa-otp input {
  width: 46px; height: 56px; padding: 0; text-align: center;
  background: transparent; color: #f5f5f5; caret-color: #f5f5f5;
  font: 600 22px/1 -apple-system, BlinkMacSystemFont, 'SF Mono', 'Segoe UI', Roboto, monospace;
  border: 1px solid #2e2e2e; border-radius: 0; outline: none;
  -webkit-appearance: none; appearance: none;
  transition: border-color .15s, transform .15s;
}
.hqa-otp input:focus { border-color: #f5f5f5; }
.hqa-otp input::selection { background: transparent; }
.hqa-otp input.filled { border-color: #6b6b6b; }
.hqa-otp.error input { border-color: #ed4956; animation: hqa-shake .35s; }
.hqa-otp.done input { border-color: #f5f5f5; }
@keyframes hqa-shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@media (max-width: 360px) { .hqa-otp { gap: 6px; } .hqa-otp input { width: 40px; height: 50px; font-size: 20px; } }

/* ── เอกสารข้อตกลง (ต้องเลื่อนอ่านจนจบ) ── */
.hqa-legal { height: min(52vh, 460px); overflow-y: auto; border: 1px solid #2e2e2e; background: #0d0d0d; padding: 16px 16px 24px;
  font-size: 12.5px; line-height: 1.7; color: #bdbdbd; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.hqa-legal h3 { color: #f5f5f5; font-size: 14px; margin: 18px 0 8px; text-align: left; }
.hqa-legal h3.lg-title { text-align: center; font-size: 15px; margin: 0 0 14px; line-height: 1.5; }
.hqa-legal h3.lg-title small { font-size: 11.5px; font-weight: 500; color: #8e8e8e; }
/* จัดแบบเอกสารรายงาน: เต็มบรรทัด (กระจายช่องไฟ) · ย่อหน้าเยื้อง · ข้อย่อย 1.1 แขวนเลขไว้ด้านซ้าย */
.hqa-legal p { margin: 0 0 8px; text-align: justify; text-justify: inter-character; text-indent: 2em; hyphens: auto; }
.hqa-legal p.lg-sub { text-indent: 0; padding-left: 2.9em; position: relative; }
.hqa-legal .lg-n { position: absolute; left: 0; top: 0; color: #d6d6d6; font-weight: 600; font-variant-numeric: tabular-nums; }
.hqa-legal-hint { text-align: center; font-size: 12px; color: #8e8e8e; }
.hqa-check { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 13px; color: #d6d6d6; line-height: 1.5; cursor: pointer; white-space: nowrap; }
.hqa-check input { margin-top: 0; accent-color: #ed4956; width: 16px; height: 16px; flex-shrink: 0; }
.hqa-check.disabled { opacity: .45; }   /* ยังกดได้ — แตะแล้วบอกว่าต้องทำอะไรก่อน */
/* หน้าข้อตกลง: ทั้งหน้าพอดีจอ ไม่เลื่อน — เลื่อนอ่านเฉพาะในกล่องเอกสาร (ความสูงกล่องคำนวณให้พอดีจอทุกแนว) */
html .hqa-screen.hqa-legal-mode { overflow: hidden; padding-bottom: max(calc(env(safe-area-inset-bottom) - 6px), 18px); min-height: 0; height: 100%; }
/* HQUX ห่างปุ่มย้อนกลับ/ถัดไปลงมาเยอะๆ แต่ไม่ชิดขอบล่าง (padding นับรวมใน offsetHeight ที่ fitLegal ใช้) */
html .hqa-screen.hqa-legal-mode .hqa-foot { padding-top: 34px; }
@media (max-height: 520px) {   /* แนวนอน/จอเตี้ย: เก็บที่ให้เอกสาร */
  html .hqa-screen.hqa-legal-mode .hqa-logo { display: none; }
  html .hqa-screen.hqa-legal-mode .hqa-title { font-size: 15px; margin-bottom: 0; }
  html .hqa-screen.hqa-legal-mode .hqa-sub { margin-bottom: 2px; }
  html .hqa-screen.hqa-legal-mode .hqa-nav { margin-top: 0; }
  html .hqa-screen.hqa-legal-mode .hqa-step { gap: 6px; }
  html .hqa-screen.hqa-legal-mode .hqa-foot { padding-top: 14px; }
}
@media (orientation: landscape) {   /* แนวนอน: กล่องเอกสารกว้างขึ้นให้อ่านสบาย */
  html .hqa-screen.hqa-legal-mode .hqa-main { max-width: min(680px, 94vw); }
}
.hqa-screen.hqa-legal-mode .hqa-main { padding: 54px 0 6px; justify-content: flex-start; }   /* โลโก้ไม่ชิดขอบบน */
@media (max-height: 520px) { .hqa-screen.hqa-legal-mode .hqa-main { padding-top: 8px; } }   /* แนวนอน: ไม่มีโลโก้ เก็บที่ให้เอกสาร */
.hqa-screen.hqa-legal-mode .hqa-logo { margin-bottom: 14px; }
.hqa-screen.hqa-legal-mode .hqa-logo img { width: 44px; height: 44px; }
.hqa-legal-next-off { opacity: .25 !important; }   /* กดได้ — แตะแล้วบอกขั้นตอนที่ยังขาด */

/* ── ตัวเลือกวิธียืนยัน/วิธีกู้บัญชี ── */
.hqa-choice { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; background: #0d0d0d; border: 1px solid #2e2e2e;
  color: #f5f5f5; font-family: inherit; text-align: left; cursor: pointer; transition: border-color .2s; }
.hqa-choice:active { border-color: #8e8e8e; }
.hqa-choice i { font-size: 22px; color: #d6d6d6; flex-shrink: 0; }
.hqa-choice b { display: block; font-size: 14px; font-weight: 600; }
.hqa-choice span { display: block; font-size: 12px; color: #8e8e8e; margin-top: 2px; line-height: 1.4; }

/* ── แบบทดสอบกู้บัญชี ── */
.hqa-quiz-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #8e8e8e; }
.hqa-quiz-bar { height: 2px; background: #2e2e2e; position: relative; overflow: hidden; }
.hqa-quiz-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: #f5f5f5; transition: width .3s; }
.hqa-timer { height: 3px; background: #2e2e2e; overflow: hidden; }
.hqa-timer i { display: block; height: 100%; background: #f5f5f5; transform-origin: left; }
.hqa-timer.low i { background: #ed4956; }
.hqa-q { font-size: 16px; font-weight: 600; line-height: 1.5; color: #f5f5f5; margin: 6px 0 4px; }
.hqa-opts { display: flex; flex-direction: column; gap: 8px; }
.hqa-opt { width: 100%; text-align: left; padding: 12px 14px; background: #0d0d0d; border: 1px solid #2e2e2e; color: #f5f5f5;
  font-family: inherit; font-size: 14px; cursor: pointer; line-height: 1.4; word-break: break-word; }
.hqa-opt.sel { border-color: #f5f5f5; background: #1a1a1a; }
.hqa-textarea { width: 100%; min-height: 110px; padding: 12px 14px; background: #0d0d0d; color: #f5f5f5; border: 1px solid #2e2e2e;
  font: 15px/1.5 inherit; outline: none; resize: vertical; }
.hqa-textarea:focus { border-color: #8e8e8e; }
.hqa-score { text-align: center; font-size: 46px; font-weight: 800; letter-spacing: -1px; color: #f5f5f5; }
.hqa-score.fail { color: #ed4956; }
.hqa-bigcode { text-align: center; font: 800 64px/1 -apple-system, BlinkMacSystemFont, 'SF Mono', monospace; letter-spacing: 8px; color: #f5f5f5; margin: 8px 0; }
.hqa-files { display: flex; gap: 8px; flex-wrap: wrap; }
.hqa-files img { width: 64px; height: 64px; object-fit: cover; border: 1px solid #2e2e2e; }

.hqa-spin { width: 18px; height: 18px; border: 2px solid rgba(0,0,0,.2); border-top-color: #000; border-radius: 50%; animation: hqa-rot .8s linear infinite; }
.hqa-loader { position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.75); }
.hqa-loader.show { display: flex; }
.hqa-loader span { width: 28px; height: 28px; border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: hqa-rot .8s linear infinite; }
@keyframes hqa-rot { to { transform: rotate(360deg); } }
