/* ============================================================
   ThaiEduHub — สไตล์หลัก (ไฟล์เดียว ไม่มี build step)
   ทุกคลาส scope ใต้ body.th เพื่อไม่ชนกับ CSS อื่นในอนาคต
   ============================================================ */

body.th {
  --blue:       #2563eb;   /* สีหลัก ปุ่ม ลิงก์ */
  --blue-l:     #dbeafe;   /* พื้นอ่อน แถบไฮไลต์ */
  --blue-d:     #1d4ed8;   /* hover / กดค้าง */
  --blue-t:     #1e40af;   /* ตัวอักษรสีน้ำเงินบนพื้นขาว */
  --blue-soft:  rgba(37, 99, 235, 0.10);
  --paper:      #f7f9fc;
  --white:      #ffffff;
  --navy:       #16233a;
  --ink:        #1f1f1f;
  --text:       #3c4654;
  --muted:      #6b7686;
  --line:       #e2e8f0;
  --line2:      #f1f5f9;
  --red:        #b91c1c;
  --red-soft:   rgba(185, 28, 28, 0.08);
  --green:      #15803d;
  --green-soft: rgba(21, 128, 61, 0.10);
  --amber:      #92400e;
  --amber-soft: #fef3c7;
  --navy-2:     #223454;   /* ไล่สีคู่กับ navy ในแถบหัวเรื่อง */
  --radius:     16px;
  --radius-lg:  22px;
  --shadow:     0 1px 2px rgba(22, 35, 58, .05), 0 10px 30px rgba(22, 35, 58, .06);
  --shadow-up:  0 2px 4px rgba(22, 35, 58, .06), 0 18px 44px rgba(22, 35, 58, .11);
  --font:       "IBM Plex Sans Thai", "Sarabun", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* ใช้ family เดียวทั้งเว็บ ลดการโหลดฟอนต์ลงครึ่งหนึ่ง
     หัวเรื่องแยกด้วยน้ำหนักและระยะห่างตัวอักษรแทนการเปลี่ยนแบบอักษร */
  --font-head:  "IBM Plex Sans Thai", -apple-system, BlinkMacSystemFont, sans-serif;

  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;

  /* แสงนวล ๆ ด้านบนของหน้า ให้ไม่แบนจนเกินไป */
  background-image:
    radial-gradient(900px 420px at 12% -8%, rgba(37, 99, 235, .07), transparent 60%),
    radial-gradient(760px 380px at 92% 2%, rgba(37, 99, 235, .05), transparent 62%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}
body.th * { box-sizing: border-box; }

body.th .wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }
body.th .wrap-wide { max-width: 1180px; }

body.th .skip { position: absolute; left: -9999px; }
body.th .skip:focus { left: 8px; top: 8px; z-index: 50; background: var(--white); padding: 8px 14px; border-radius: 8px; }

/* ---------- แถบบน ---------- */
body.th .top {
  background: linear-gradient(100deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #e7edf6; position: sticky; top: 0; z-index: 30;
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 8px 24px rgba(22, 35, 58, .16);
}
body.th .top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; flex-wrap: wrap; }
body.th .brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; }
body.th .brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(140deg, #3b82f6, var(--blue-d)); color: #fff;
  font-size: 14px; letter-spacing: .5px; font-family: var(--font-head);
  box-shadow: 0 4px 12px rgba(37, 99, 235, .4);
}
body.th .brand-txt { font-size: 16px; font-family: var(--font-head); font-weight: 600; letter-spacing: .1px; }
body.th .menu { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; }
body.th .menu a { color: #cfdcef; text-decoration: none; font-size: 15px; padding: 7px 12px; border-radius: 999px; transition: background .15s ease, color .15s ease; }
body.th .menu a:hover { color: #fff; background: rgba(255,255,255,.1); }
body.th .menu .btn-ghost { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.2); }
body.th .menu .btn-ghost:hover { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.3); color: #fff; }
body.th .menu .who { color: #93a7c4; font-size: 14px; }
body.th .logout-f { display: inline; }
body.th .navtoggle {
  display: none; align-items: center; gap: 8px; background: rgba(255,255,255,.12);
  color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: 10px;
  font: inherit; font-size: 15px; font-weight: 600; padding: 8px 14px; min-height: 44px; cursor: pointer;
}
body.th .navtoggle:hover { background: rgba(255,255,255,.2); }
body.th .navtoggle-bars { display: grid; gap: 3px; }
body.th .navtoggle-bars i { display: block; width: 17px; height: 2px; background: currentColor; border-radius: 2px; }

/* ---------- พื้นฐานข้อความ ---------- */
/* ต้องระบุ main.wrap ให้แรงกว่า .wrap ไม่งั้น padding: 0 16px ของ .wrap ชนะ
   แล้ว hero จะไปชิดแถบเมนูด้านบน */
body.th main.wrap { display: block; padding: 28px 16px 56px; }
body.th .h1 { font-family: var(--font-head); font-weight: 700; font-size: 34px; line-height: 1.3; color: var(--navy); margin: 0 0 6px; letter-spacing: -.4px; }
body.th .h2 { font-family: var(--font-head); font-weight: 700; font-size: 22px; color: var(--navy); margin: 0 0 10px; letter-spacing: -.2px; }
body.th .h3 { font-weight: 600; font-size: 18px; color: var(--navy); margin: 0 0 6px; }
body.th .sub-h {
  margin: 30px 0 14px; padding: 0 0 0 13px; border-bottom: 0;
  border-left: 4px solid var(--blue); border-radius: 2px; line-height: 1.4;
}
body.th .mt { margin-top: 28px; }
body.th .muted { color: var(--muted); }
body.th .sm { font-size: 14px; }
body.th .eyebrow {
  display: inline-block; color: var(--blue-t); font-size: 13.5px; font-weight: 600;
  margin: 0 0 8px; letter-spacing: .2px; background: var(--blue-l);
  padding: 4px 13px; border-radius: 999px;
}
body.th a { color: var(--blue-t); }
body.th code { background: var(--line2); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
body.th kbd {
  background: var(--white); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; padding: 1px 7px; font-size: 13px; color: var(--navy);
}
body.th .r { text-align: right; }
body.th .warn { color: var(--amber); }

/* ---------- การ์ด ---------- */
body.th .card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; margin: 0 0 18px; box-shadow: var(--shadow);
}
body.th .card-narrow { max-width: 460px; margin-inline: auto; padding: 28px 28px 24px; border-radius: var(--radius-lg); }
body.th .card-accent { border-left: 4px solid var(--blue); }
body.th .row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
body.th .row-gap { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
body.th .inline { display: inline; }
body.th .plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
body.th .meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); margin: 8px 0; }
body.th .note {
  background: var(--amber-soft); border: 1px solid #fcd34d; color: #713f12;
  border-radius: 10px; padding: 12px 14px; font-size: 15px;
}

/* ---------- ปุ่ม ---------- */
body.th .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(140deg, #3b82f6, var(--blue-d));
  color: #fff; border: 1px solid transparent;
  padding: 11px 22px; border-radius: 12px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; min-height: 46px;   /* นิ้วกดได้บนมือถือ */
  box-shadow: 0 2px 6px rgba(37, 99, 235, .25), 0 10px 22px rgba(37, 99, 235, .18);
  transition: box-shadow .18s ease, transform .12s ease, background .15s ease;
}
body.th .btn:hover  { background: linear-gradient(140deg, var(--blue), #1e40af); box-shadow: 0 4px 10px rgba(37,99,235,.3), 0 16px 32px rgba(37,99,235,.24); transform: translateY(-1px); }
body.th .btn:active { transform: translateY(1px); box-shadow: 0 1px 3px rgba(37,99,235,.3); }
body.th .btn-ghost  { background: var(--white); color: var(--blue-t); border-color: var(--line); box-shadow: 0 1px 2px rgba(22,35,58,.05); }
body.th .btn-ghost:hover { background: var(--blue-l); border-color: #bfdbfe; color: var(--blue-t); box-shadow: 0 4px 14px rgba(22,35,58,.08); }
body.th .btn-sm { padding: 7px 14px; min-height: 38px; font-size: 14px; }
body.th .btn-lg { padding: 14px 30px; font-size: 17px; width: 100%; min-height: 52px; border-radius: 13px; }
body.th .btn[disabled] { opacity: .45; cursor: not-allowed; }
body.th :focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- ฟอร์ม ---------- */
body.th .form { display: grid; gap: 14px; margin: 16px 0; }
body.th .form label { display: grid; gap: 6px; font-size: 15px; color: var(--navy); font-weight: 600; }
body.th input[type=text], body.th input[type=email], body.th input[type=password] {
  font: inherit; padding: 12px 15px; border: 1px solid var(--line); border-radius: 12px;
  background: #fbfcfe; color: var(--ink); width: 100%; min-height: 50px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
body.th input:focus { border-color: var(--blue); outline: none; background: var(--white); box-shadow: 0 0 0 4px var(--blue-soft); }

/* ---------- แจ้งเตือน ---------- */
body.th .flash { border-radius: 10px; padding: 11px 15px; margin: 0 0 14px; font-size: 15px; }
body.th .flash-ok  { background: var(--green-soft); color: var(--green); border: 1px solid rgba(21,128,61,.25); }
body.th .flash-bad { background: var(--red-soft);   color: var(--red);   border: 1px solid rgba(185,28,28,.25); }

/* ---------- ป้าย ---------- */
body.th .chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px;
  background: var(--line2); color: var(--text);
  /* ไม่ใช้ nowrap กับทุกป้าย เพราะชื่อหัวข้อหลักสูตรยาวมากจนดันจอล้น
     ป้ายสั้น ๆ ที่ไม่ควรตัดบรรทัด (เช่น เวลา) ให้ใส่ .chip-nowrap เอง */
  overflow-wrap: anywhere;
}
body.th .chip-nowrap { white-space: nowrap; }
body.th .chip-blue { background: var(--blue); color: #fff; }
body.th .chip-soft { background: var(--blue-l); color: var(--blue-t); }
body.th .chip-warn { background: var(--amber-soft); color: var(--amber); }
body.th .badge { display: inline-block; padding: 2px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; }
body.th .badge-ok   { background: var(--green-soft); color: var(--green); }
body.th .badge-bad  { background: var(--red-soft);   color: var(--red); }
body.th .badge-warn { background: var(--amber-soft); color: var(--amber); }
body.th .badge-none { background: var(--line2);      color: var(--muted); }

/* ---------- สถิติ ---------- */
body.th .hero { display: grid; gap: 18px; margin-bottom: 22px; }
body.th .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
body.th .stat {
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 10px; text-align: center;
}
body.th .stat-n { display: block; font-size: 26px; font-weight: 700; color: var(--blue-t); line-height: 1.2; font-variant-numeric: tabular-nums; }
body.th .stat-l { display: block; font-size: 13px; color: var(--muted); }
body.th .stats-row { margin-bottom: 18px; }

/* ---------- แถบเปอร์เซ็นต์ ---------- */
body.th .bars { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 12px; }
body.th .bar { height: 9px; background: var(--line2); border-radius: 999px; overflow: hidden; }
body.th .bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--blue); transition: width .7s cubic-bezier(.33,1,.68,1); }
body.th .bar-fill.is-low { background: var(--red); }
body.th .bar-fill.is-mid { background: #b45309; }
body.th .bar-fill.is-ok  { background: var(--green); }

/* ---------- แท็บ ---------- */
body.th .tabs {
  display: inline-flex; gap: 4px; flex-wrap: wrap; margin: 8px 0 20px;
  background: #eef2f8; border: 1px solid var(--line); border-radius: 999px; padding: 5px;
}
body.th .tab {
  font: inherit; font-weight: 600; font-size: 15px; background: none; border: 0; cursor: pointer;
  padding: 9px 20px; color: var(--muted); border-radius: 999px; min-height: 42px;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
body.th .tab[aria-selected="true"], body.th .tab.is-now {
  color: var(--blue-t); background: var(--white);
  box-shadow: 0 1px 2px rgba(22,35,58,.08), 0 6px 16px rgba(22,35,58,.07);
}
body.th .tab:hover { color: var(--navy); }

/* ---------- การ์ดชุดข้อสอบ ---------- */
/* minmax ขั้นต่ำต้องเป็น 0 ไม่งั้นบนจอ 320px (เหลือพื้นที่ ~288px) การ์ดจะล้นออกนอกจอ
   ใช้ auto-fit + clamp แทน : จอเล็กได้ 1 คอลัมน์ จอใหญ่ค่อยเพิ่มเอง */
body.th .grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
}
body.th .bank {
  margin: 0; display: flex; flex-direction: column; position: relative; overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
/* เส้นสีด้านบนการ์ด — โผล่เมื่อชี้เมาส์ ให้รู้ว่ากดได้ */
body.th .bank::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, #3b82f6, var(--blue-d));
  transform: scaleX(0); transform-origin: left; transition: transform .25s ease;
}
body.th .bank:hover { transform: translateY(-3px); box-shadow: var(--shadow-up); border-color: #cfe0fb; }
body.th .bank:hover::before { transform: scaleX(1); }
body.th .bank-go { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 16px; }
body.th .bank-go .btn { flex: 1 1 auto; }

/* ---------- หน้าทำข้อสอบ ---------- */
body.th.exam-mode { background: var(--white); }
body.th .exam { max-width: 780px; margin-inline: auto; }
body.th .exam-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 14px;
}
body.th .exam-top-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
body.th .timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 21px; color: var(--navy);
  background: var(--blue-l); padding: 4px 12px; border-radius: 10px;
}
body.th .timer.is-low { background: var(--red-soft); color: var(--red); }
body.th .savestate { font-size: 13px; color: var(--muted); min-width: 92px; }
body.th .savestate.is-bad { color: var(--red); font-weight: 600; }

body.th .pad { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
body.th .pad-b {
  font: inherit; font-size: 14px; width: 44px; height: 44px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--white); color: var(--muted);
}
body.th .pad-b.is-done { background: var(--blue-l); color: var(--blue-t); border-color: var(--blue-l); font-weight: 600; }
body.th .pad-b.is-now  { outline: 3px solid var(--blue); outline-offset: 1px; color: var(--navy); }

body.th .q-no { font-weight: 700; color: var(--navy); margin: 0 0 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
body.th .q-text { font-size: 18px; color: var(--ink); margin: 0 0 16px; }
body.th .choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
body.th .choice {
  display: flex; gap: 11px; align-items: flex-start; cursor: pointer;
  border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; background: var(--white);
  transition: border-color .15s ease, background .15s ease;
}
body.th .choice:hover { border-color: var(--blue); background: var(--blue-soft); }
body.th .choice input { margin: 5px 0 0; accent-color: var(--blue); flex: none; }
body.th .choice-k { font-weight: 700; color: var(--blue-t); flex: none; min-width: 18px; }
body.th .choice-t { flex: 1; }
body.th .choice.is-picked { border-color: var(--blue); background: var(--blue-soft); }
body.th .choices-static .choice { cursor: default; }
body.th .choice.is-answer { border-color: var(--green); background: var(--green-soft); }
body.th .choice.is-wrong  { border-color: var(--red);   background: var(--red-soft); }
body.th .tag-ok  { font-size: 13px; font-weight: 700; color: var(--green); flex: none; }
body.th .tag-bad { font-size: 13px; font-weight: 700; color: var(--red);   flex: none; }

body.th .reveal { margin-top: 14px; border-radius: 11px; padding: 13px 15px; font-size: 15px; }
body.th .reveal.is-ok  { background: var(--green-soft); border: 1px solid rgba(21,128,61,.25); }
body.th .reveal.is-bad { background: var(--red-soft);   border: 1px solid rgba(185,28,28,.25); }
body.th .explain { background: var(--blue-l); border-radius: 10px; padding: 12px 14px; margin: 14px 0 0; font-size: 15px; color: var(--navy); }

body.th .q-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
body.th .exam-end { margin-top: 18px; text-align: center; }
body.th .kbd-hint { text-align: center; margin-top: 14px; }

/* ---------- ผลสอบ ---------- */
body.th .score { text-align: center; }
body.th .score-n .stat-n { font-size: 56px; }
body.th .score-sub { margin: 0 0 12px; }
body.th .pills { list-style: none; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 0; margin: 0; }
body.th .pill { background: var(--line2); border-radius: 999px; padding: 4px 14px; font-size: 14px; }
body.th .pill-ok  { background: var(--green-soft); color: var(--green); }
body.th .pill-bad { background: var(--red-soft);   color: var(--red); }
body.th .ans { border-left: 4px solid var(--line); }
body.th .ans.is-ok    { border-left-color: var(--green); }
body.th .ans.is-bad   { border-left-color: var(--red); }
body.th .ans.is-blank { border-left-color: var(--muted); }

/* ---------- ตาราง ---------- */
body.th .tablewrap { overflow-x: auto; }
body.th .tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
body.th .tbl th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
body.th .tbl td { padding: 10px; border-bottom: 1px solid var(--line2); }
body.th .tbl tr:hover td { background: var(--paper); }

/* ---------- หน้าตรวจไฟล์ ---------- */
body.th .chk.is-ok   { border-left: 4px solid var(--green); }
body.th .chk.is-warn { border-left: 4px solid #d97706; }
body.th .chk.is-bad  { border-left: 4px solid var(--red); }
body.th .msgbox { border-radius: 11px; padding: 13px 15px; margin: 12px 0; font-size: 15px; }
body.th .msg-bad  { background: var(--red-soft);   border: 1px solid rgba(185,28,28,.25); }
body.th .msg-warn { background: var(--amber-soft); border: 1px solid #fcd34d; color: #713f12; }
body.th .copybox {
  width: 100%; font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  border: 1px solid var(--line); border-radius: 9px; padding: 10px; margin: 8px 0; background: var(--white);
  color: var(--ink); resize: vertical;
}
body.th .qlist summary, body.th .msgbox summary { cursor: pointer; font-weight: 600; color: var(--navy); }
body.th .chk-q { border-top: 1px solid var(--line2); padding: 16px 0 4px; }

/* ---------- ท้ายหน้า ---------- */
body.th .foot { border-top: 1px solid var(--line); padding: 22px 0 36px; color: var(--muted); font-size: 14px; background: var(--white); }
body.th .foot p { margin: 2px 0; }
body.th .foot-nav { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line2); }
body.th .foot-nav a { text-decoration: none; font-size: 14.5px; }
body.th .foot-nav a:hover { text-decoration: underline; }

/* ============================================================
   ส่วนที่เพิ่มรอบปรับหน้าตา (ต.ค. 2026)
   ยึดโครงจากต้นแบบ i-TEST PRO แต่ใช้โทนน้ำเงิน-ขาวของเราเอง
   ============================================================ */

/* ---------- แถบหัวเรื่องสีเข้ม (หน้าแรก) ---------- */
body.th .hero-band {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--navy) 0%, #1d3050 55%, #1e3a6b 100%);
  border-radius: var(--radius-lg); padding: 32px 32px 28px; margin: 4px 0 26px;
  color: #dbe5f3; box-shadow: 0 10px 34px rgba(22, 35, 58, .22);
}
/* แสงนวลมุมขวาบน ให้พื้นไม่ทึบตัน */
body.th .hero-band::after {
  content: ""; position: absolute; width: 460px; height: 460px; right: -130px; top: -230px;
  background: radial-gradient(circle, rgba(59, 130, 246, .40), transparent 68%);
  pointer-events: none;
}
body.th .hero-band > * { position: relative; z-index: 1; }
body.th .hero-band .eyebrow { background: rgba(255,255,255,.12); color: #bfdbfe; }
body.th .hero-band .h1 { color: #fff; font-size: 38px; margin-bottom: 10px; }
body.th .hero-band .muted { color: #a9bcd8; }
/* ใช้ :not(.btn) เพราะเดิมกฎนี้ไปทับสีตัวอักษรของปุ่มด้วย
   ทำให้ปุ่ม "เข้าสู่ระบบ" เป็นฟ้าอ่อนบนพื้นขาว อ่านแทบไม่ออก */
body.th .hero-band a:not(.btn) { color: #bfdbfe; }
body.th .hero-band .btn { color: #fff; }
body.th .hero-band .btn-ghost { background: #fff; color: var(--blue-d); border-color: #fff; }
body.th .hero-band .btn-ghost:hover { background: #eaf1ff; color: var(--blue-d); border-color: #eaf1ff; }

/* ตัวเลขสถิติบนแถบเข้ม — เส้นคั่นบาง ๆ แบบต้นแบบ ไม่ใช่กล่องสี่เหลี่ยม */
body.th .hero-band .stats { margin-top: 24px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.14); gap: 8px; }
body.th .hero-band .stat { background: none; border: 0; padding: 4px 6px; text-align: left; }
body.th .hero-band .stat + .stat { border-left: 1px solid rgba(255,255,255,.12); padding-left: 18px; }
body.th .hero-band .stat-n { color: #fff; font-family: var(--font-head); font-size: 30px; }
body.th .hero-band .stat-l { color: #93a7c4; }
/* ---------- การ์ด "ทำต่อ" บนแถบหัวเรื่อง ---------- */
body.th .resume { display: grid; gap: 10px; margin: 22px 0 4px; }
body.th .resume-card {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  border-radius: 14px; padding: 14px 16px;
}
body.th .resume-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 7px; flex-wrap: wrap; }
body.th .resume-tag { font-size: 12.5px; color: #bfdbfe; font-weight: 600; letter-spacing: .2px; }
body.th .resume-time { font-size: 13px; color: #cfe0fb; font-variant-numeric: tabular-nums; }
body.th .resume-time.is-low { color: #fca5a5; font-weight: 600; }
body.th .resume-title { margin: 0 0 11px; color: #fff; font-weight: 600; font-size: 16.5px; line-height: 1.5; }
body.th .resume-bar { background: rgba(255,255,255,.18); height: 8px; }
body.th .resume-go { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 11px; flex-wrap: wrap; }
body.th .resume-go .sm { color: #bccbe2; }
body.th .resume-go .btn { background: #fff; color: var(--blue-d); border-color: #fff; box-shadow: none; }
body.th .resume-go .btn:hover { background: #eaf1ff; color: var(--blue-d); }

body.th .hero-foot { margin: 16px 0 0; color: #93a7c4; }
body.th .hero-foot a { color: #bfdbfe; }

/* ---------- หน้าเข้าสู่ระบบ / สมัครสมาชิก ---------- */
body.th .auth-brand { text-align: center; margin: 26px 0 20px; }
body.th .auth-mark {
  display: inline-grid; place-items: center; width: 60px; height: 60px; border-radius: 18px;
  background: linear-gradient(140deg, #3b82f6, var(--blue-d)); color: #fff;
  font-family: var(--font-head); font-weight: 700; font-size: 21px; letter-spacing: .5px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, .36);
}
body.th .auth-brand h1 { font-family: var(--font-head); font-weight: 600; font-size: 21px; color: var(--navy); margin: 14px 0 2px; }
body.th .auth-brand p { margin: 0; color: var(--muted); font-size: 15px; }
body.th .auth-foot { text-align: center; margin-top: 18px; }

/* ---------- วงแหวนคะแนน (หน้าผลสอบ) ---------- */
body.th .gauge {
  --v: 0;                                   /* เปอร์เซ็นต์ที่ได้ ใส่ผ่าน style="--v:72" */
  width: 184px; height: 184px; border-radius: 50%; margin: 6px auto 16px;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--gc, var(--blue)) calc(var(--v) * 1%), var(--line2) 0);
  transition: background .8s cubic-bezier(.33,1,.68,1);
}
body.th .gauge::before {
  content: ""; position: absolute; inset: 13px; border-radius: 50%;
  background: var(--white); box-shadow: inset 0 2px 10px rgba(22,35,58,.07);
}
body.th .gauge-in { position: relative; text-align: center; line-height: 1.15; }
body.th .gauge.is-ok  { --gc: var(--green); }
body.th .gauge.is-bad { --gc: var(--red); }
body.th .score-n { margin: 0; }
body.th .gauge .stat-n { font-family: var(--font-head); font-size: 46px; color: var(--navy); }
body.th .gauge-l { display: block; font-size: 13px; color: var(--muted); }

/* ---------- ไอคอนประจำการ์ด ---------- */
body.th .ico {
  display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none;
  border-radius: 13px; background: var(--blue-l); color: var(--blue-t);
  font-size: 19px; font-weight: 700;
}
body.th .card-head { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 4px; }
body.th .card-head .h3, body.th .card-head .h2 { margin: 0; }

/* ---------- แถบเปอร์เซ็นต์ให้หนาขึ้นอ่านง่ายขึ้น ---------- */
body.th .bar { height: 11px; background: #eef2f8; }
body.th .bar-fill { box-shadow: inset 0 -1px 2px rgba(0,0,0,.08); }

/* ---------- ท้ายหน้า ---------- */
body.th .foot { background: var(--white); border-top: 1px solid var(--line); }

/* ---------- เมนูย่อยบนแถบบน ---------- */
body.th .dd { position: relative; }
body.th .dd > summary {
  list-style: none; cursor: pointer; color: #cfdcef; font-size: 15px;
  padding: 7px 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s ease, color .15s ease;
}
body.th .dd > summary::-webkit-details-marker { display: none; }
body.th .dd > summary::after { content: "▾"; font-size: 11px; opacity: .8; }
body.th .dd > summary:hover { color: #fff; background: rgba(255,255,255,.1); }
body.th .dd[open] > summary { color: #fff; background: rgba(255,255,255,.14); }
body.th .dd-menu {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 40; min-width: 280px;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: 8px; box-shadow: 0 16px 42px rgba(22, 35, 58, .22);
}
body.th .dd-menu a {
  display: block; color: var(--text); padding: 10px 13px; border-radius: 9px;
  font-size: 15px; text-decoration: none;
}
body.th .dd-menu a:hover { background: var(--blue-l); color: var(--blue-t); }
body.th .dd-cap { margin: 4px 13px 8px; font-size: 12.5px; color: var(--muted); letter-spacing: .2px; }
body.th .dd-note { margin: 8px 13px 4px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line2); padding-top: 9px; }

/* ---------- หน้าแรกสาธารณะ ---------- */
body.th .land-hero { padding: 48px 40px 36px; }
body.th .land-hero-in { max-width: 720px; }
body.th .land-hero .h1 { font-size: 46px; line-height: 1.25; }
body.th .land-lead { font-size: 18px; color: #bccbe2; max-width: 60ch; margin: 0 0 24px; }
body.th .land-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
body.th .btn-lg-auto { padding: 13px 28px; font-size: 16.5px; min-height: 50px; border-radius: 13px; }
body.th .land-hero .stats { grid-template-columns: repeat(4, auto); justify-content: start; }

/* ---------- การ์ดตัวอย่างผลวิเคราะห์ข้าง hero ---------- */
body.th .land-hero-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 36px; align-items: center; }
body.th .demo {
  background: #fff; border-radius: 18px; padding: 20px 22px; color: var(--text);
  box-shadow: 0 18px 50px rgba(8, 18, 38, .38);
}
body.th .demo-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
body.th .demo-title { font-family: var(--font-head); font-weight: 600; color: var(--navy); font-size: 16px; }
body.th .demo-tag { font-size: 11.5px; font-weight: 600; color: var(--amber); background: var(--amber-soft); border-radius: 999px; padding: 3px 10px; }
body.th .demo-score { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
body.th .demo-pct { font-family: var(--font-head); font-weight: 700; font-size: 38px; color: var(--blue-t); line-height: 1; }
body.th .demo-pct small { font-size: 18px; }
body.th .demo-note { font-size: 13px; color: var(--muted); }
body.th .demo-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
body.th .demo-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 5px; }
body.th .demo-row b { font-variant-numeric: tabular-nums; color: var(--navy); }
body.th .demo .bar { display: block; }
body.th .demo .bar-fill { transition: none; }
body.th .demo-foot { margin: 15px 0 0; padding-top: 13px; border-top: 1px solid var(--line2); font-size: 13.5px; color: var(--text); }

body.th .land-sec { margin: 44px 0; }
body.th .land-head { margin-bottom: 20px; }
body.th .land-h2 { font-size: 29px; line-height: 1.35; margin-bottom: 8px; }
body.th .land-head .muted { max-width: 64ch; }

body.th .grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); }
body.th .grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }

body.th .feat .ico { margin-bottom: 12px; }
body.th .feat .h3 { margin-bottom: 6px; }

/* การ์ดตำแหน่ง/บทความ กดได้ทั้งใบ */
body.th .track-card { text-decoration: none; color: inherit; }
body.th .track-card .h3 { color: var(--navy); }
body.th .track-go { margin-top: auto; padding-top: 14px; color: var(--blue-t); font-weight: 600; font-size: 15px; }
body.th .post-card .h3 a { text-decoration: none; color: var(--navy); }
body.th .post-card .h3 a:hover { color: var(--blue-t); }
body.th .post-meta { margin: 0 0 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
body.th .cta-card { text-align: center; background: linear-gradient(135deg, #eff5ff, #e4edfd); border-color: #cfe0fb; }

/* ---------- บทความ ---------- */
body.th .crumb { margin: 2px 0 14px; color: var(--muted); }
body.th .crumb a { text-decoration: none; }
body.th .art { max-width: 760px; margin-inline: auto; padding: 30px 34px 34px; }
body.th .art-title { font-size: 36px; line-height: 1.3; margin-bottom: 12px; }
body.th .art-lead { font-size: 18.5px; color: var(--navy); border-left: 4px solid var(--blue); padding-left: 16px; margin: 0 0 24px; }
body.th .art-body { font-size: 17.5px; line-height: 1.95; }
body.th .art-body p { margin: 0 0 18px; }
body.th .art-h { margin: 30px 0 10px; font-size: 23px; }
body.th .art-ul { margin: 0 0 18px; padding-left: 22px; }
body.th .art-ul li { margin-bottom: 7px; }

body.th .pager { display: flex; gap: 7px; justify-content: center; margin: 28px 0 8px; flex-wrap: wrap; }
body.th .pager-b {
  min-width: 44px; min-height: 44px; display: grid; place-items: center; text-decoration: none;
  border: 1px solid var(--line); border-radius: 11px; background: var(--white); color: var(--text); font-weight: 600;
}
body.th .pager-b.is-now { background: var(--blue); border-color: var(--blue); color: #fff; }

/* แท็บที่เป็นลิงก์ (ไม่ใช่ปุ่ม) ต้องหน้าตาเหมือนกัน */
body.th a.tab { text-decoration: none; display: inline-flex; align-items: center; }

/* ---------- ฟอร์มเขียนบทความ ---------- */
body.th .ta, body.th .sel {
  font: inherit; width: 100%; padding: 12px 15px; border: 1px solid var(--line);
  border-radius: 12px; background: #fbfcfe; color: var(--ink);
}
body.th .ta { resize: vertical; line-height: 1.8; min-height: 70px; }
body.th .ta-lg { min-height: 340px; font-size: 16px; }
body.th .ta:focus, body.th .sel:focus { border-color: var(--blue); outline: none; background: var(--white); box-shadow: 0 0 0 4px var(--blue-soft); }
body.th .sel { min-height: 50px; }

/* ---------- ติดต่อเรา ---------- */
body.th .contact-list li { padding: 11px 0; border-bottom: 1px solid var(--line2); }
body.th .contact-list li:last-child { border-bottom: 0; }
body.th .faq { border-bottom: 1px solid var(--line2); padding: 11px 0; }
body.th .faq:last-child { border-bottom: 0; }
body.th .faq summary { cursor: pointer; font-weight: 600; color: var(--navy); }
body.th .faq p { margin: 8px 0 2px; }

/* ---------- ปักหมุดข้อที่ยังไม่มั่นใจ ---------- */
body.th .flagbtn {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 5px 13px;
  border: 1px solid var(--line); background: var(--white); color: var(--muted); border-radius: 999px;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
body.th .flagbtn:hover { border-color: #fcd34d; color: var(--amber); background: var(--amber-soft); }
body.th .flagbtn.is-on { background: var(--amber-soft); border-color: #fcd34d; color: var(--amber); }
body.th .flagbtn-ico { font-size: 15px; line-height: 1; }

/* เครื่องหมายมุมบนขวาของเลขข้อที่ปักหมุดไว้ */
body.th .pad-b { position: relative; }
body.th .pad-b.is-flag::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px;
  border-radius: 50%; background: #d97706; box-shadow: 0 0 0 2px var(--white);
}
body.th .pad-b[hidden] { display: none; }

body.th .padfilter { margin: -8px 0 16px; }
body.th .chipbtn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 40px;
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--white); color: var(--text);
}
body.th .chipbtn:hover { border-color: #fcd34d; background: var(--amber-soft); color: var(--amber); }
body.th .chipbtn.is-on { background: var(--amber-soft); border-color: #d97706; color: var(--amber); }

body.th #ps-flag { color: var(--amber); font-weight: 600; margin: 0 0 6px; }

/* ผลสอบ : บอกว่าข้อไหนเคยปักหมุดไว้ */
body.th .ans-flag { background: var(--amber-soft); color: var(--amber); }

/* ---------- กล่องสรุปก่อนส่งข้อสอบ ---------- */
body.th .modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(16, 26, 44, .55); padding: 16px;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
body.th .modal[hidden] { display: none; }
body.th .modal-box {
  background: var(--white); border-radius: var(--radius-lg); padding: 24px 26px;
  width: 100%; max-width: 440px; max-height: 86vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(8, 18, 38, .4);
}
body.th .modal-box:focus { outline: none; }
body.th .modal-box .h2 { margin-bottom: 10px; }
body.th .ps-count { font-size: 19px; font-weight: 600; margin: 0 0 12px; }
body.th .ps-count.is-ok   { color: var(--green); }
body.th .ps-count.is-warn { color: var(--amber); }
body.th .ps-nums { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
body.th .ps-num {
  font: inherit; font-weight: 600; min-width: 44px; min-height: 44px; cursor: pointer;
  border: 1px solid #fcd34d; background: var(--amber-soft); color: var(--amber);
  border-radius: 11px; padding: 0 10px;
}
body.th .ps-num:hover { background: #fde68a; }
body.th .modal-go { display: flex; gap: 10px; margin-top: 20px; }
body.th .modal-go .btn { flex: 1 1 auto; }

@media (max-width: 480px) {
  /* เรียงตามลำดับใน HTML เพื่อให้ลำดับที่ตาเห็นตรงกับลำดับที่ปุ่ม Tab วิ่ง
     (column-reverse ทำให้สองอย่างนี้สลับกัน ซึ่งสับสนสำหรับคนใช้คีย์บอร์ด) */
  body.th .modal-go { flex-direction: column; }
  body.th .modal-box { padding: 20px 18px; }
}

/* ---------- ตารางที่กลายเป็นการ์ดบนจอเล็ก ---------- */
body.th .weak-tag { overflow-wrap: anywhere; }
body.th .weak-num { white-space: normal; text-align: right; }
body.th .weak-ans { display: inline-block; }

@media (max-width: 720px) {
  /* ตารางที่มีหลายคอลัมน์อ่านยากมากบนมือถือ — ชื่อชุดแตกหลายบรรทัด
     และต้องเลื่อนแนวนอนหาปุ่ม จึงเปลี่ยนแต่ละแถวเป็นการ์ดแทน */
  body.th .tbl-cards, body.th .tbl-cards tbody, body.th .tbl-cards tr, body.th .tbl-cards td { display: block; width: 100%; }
  body.th .tbl-cards thead { position: absolute; left: -9999px; }   /* ซ่อนหัวตารางแต่ยังอ่านได้ด้วยโปรแกรมอ่านหน้าจอ */
  body.th .tbl-cards tr {
    border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
    margin-bottom: 12px; background: var(--white); box-shadow: 0 1px 2px rgba(22,35,58,.05);
  }
  body.th .tbl-cards tr:hover td { background: none; }
  body.th .tbl-cards td { border: 0; padding: 4px 0; text-align: left; }
  /* ชื่อชุดขึ้นเต็มบรรทัดบนสุด ไม่ต้องมีป้ายกำกับ */
  body.th .tbl-cards .t-title {
    font-size: 16.5px; font-weight: 600; color: var(--navy); line-height: 1.5;
    padding-bottom: 10px; margin-bottom: 8px; border-bottom: 1px solid var(--line2);
  }
  /* ช่องอื่นแสดงเป็น "ป้าย : ค่า" คนละฝั่ง */
  body.th .tbl-cards td[data-label]:not(.t-title) {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
  }
  body.th .tbl-cards td[data-label]:not(.t-title)::before {
    content: attr(data-label); color: var(--muted); font-size: 14px; flex: none;
  }
  body.th .tbl-cards .t-go { margin-top: 10px; }
  body.th .tbl-cards .t-go a {
    display: block; text-align: center; text-decoration: none; font-weight: 600;
    border: 1px solid var(--line); border-radius: 11px; padding: 11px; min-height: 44px;
    background: var(--blue-l); color: var(--blue-t);
  }
  body.th .tablewrap { overflow-x: visible; }
  body.th .weak-num { text-align: left; }
  body.th .weak-ans { display: block; }
}

/* ---------- จอเล็ก ---------- */
@media (max-width: 640px) {
  body.th { font-size: 16px; }
  body.th .h1 { font-size: 23px; }
  body.th .stats { grid-template-columns: repeat(2, 1fr); }
  body.th .stat-n { font-size: 23px; }
  body.th .score-n .stat-n { font-size: 44px; }
  body.th .q-text { font-size: 17px; }
  body.th .bank-go .btn { flex: 1 1 100%; }
  body.th .brand-txt { font-size: 15px; }
  body.th .hero-band { padding: 24px 20px 22px; border-radius: 18px; }
  body.th .hero-band .h1 { font-size: 27px; }
  body.th .hero-band .stat + .stat { border-left: 0; padding-left: 6px; }
  /* บนมือถือ "ทำต่อ" ต้องเห็นได้โดยไม่ต้องเลื่อน จึงให้ปุ่มเต็มความกว้าง */
  body.th .resume { margin: 18px 0 2px; }
  body.th .resume-go { flex-direction: column; align-items: stretch; gap: 10px; }
  body.th .resume-go .btn { width: 100%; }
  body.th .hero-band .stats { gap: 14px 8px; }
  body.th .card { padding: 18px 18px; }
  /* มี 7 ตำแหน่งให้เลือก ถ้าปล่อยให้ตัดบรรทัดกรอบแคปซูลจะเละ จึงให้เลื่อนแนวนอนแทน */
  body.th .tabs {
    display: flex; width: 100%; flex-wrap: nowrap; overflow-x: auto;
    border-radius: 14px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  body.th .tabs::-webkit-scrollbar { display: none; }
  body.th .tab { flex: 0 0 auto; white-space: nowrap; padding: 9px 14px; font-size: 14px; }
  body.th .gauge { width: 156px; height: 156px; }
  body.th .gauge .stat-n { font-size: 38px; }
  body.th .land-hero-grid { grid-template-columns: 1fr; gap: 26px; }
  body.th .land-hero { padding: 30px 20px 24px; }
  body.th .land-hero .h1 { font-size: 30px; }
  body.th .land-lead { font-size: 16.5px; }
  body.th .land-hero .stats { grid-template-columns: repeat(2, 1fr); }
  body.th .land-cta .btn { flex: 1 1 100%; }
  body.th .land-h2 { font-size: 23px; }
  body.th .art { padding: 22px 20px 26px; }
  body.th .art-title { font-size: 27px; }
  body.th .art-lead { font-size: 17px; }
  body.th .art-body { font-size: 17px; }
  /* ---- แถบบนบนมือถือ ----
     เดิมเมนูแตกเป็นหลายแถวจนแถบสูงเกือบ 180px และยังเป็น sticky
     จึงกินพื้นที่อ่านไปมาก ตอนนี้ซ่อนเมนูไว้ใต้ปุ่ม "เมนู" แถบเหลือราว 60px */
  body.th .top-in { min-height: 60px; flex-wrap: nowrap; }
  body.th .navtoggle { display: inline-flex; }
  /* ซ่อนเมนูตั้งแต่เริ่มวาดหน้า ไม่รอให้ JS มาพับทีหลัง
     ไม่งั้นหน้าจะกระโดดตอน JS ทำงาน (CLS พุ่ง)
     กรณี JS ไม่ทำงาน มี <noscript> ใน head สั่งให้กางเมนูไว้แทน */
  body.th .menu {
    display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 2px;
    padding: 6px 0 14px; border-top: 1px solid rgba(255,255,255,.12); margin-top: 6px;
  }
  body.th .nav-open .menu { display: flex; }
  body.th .menu a, body.th .dd > summary { padding: 11px 12px; border-radius: 10px; }
  body.th .menu .btn, body.th .menu .logout-f { width: 100%; margin-top: 6px; }
  body.th .menu .logout-f .btn { width: 100%; }
  body.th .menu .who { padding: 6px 12px; }
  /* เมนูย่อยบนมือถือ : กางลงในแถวแทนการลอยทับ */
  body.th .dd { width: 100%; }
  body.th .dd-menu { position: static; width: 100%; box-shadow: none; margin-top: 6px; border-radius: 10px; }
}

@media (max-width: 980px) {
  body.th .land-hero-grid { grid-template-columns: 1fr; gap: 26px; }
  body.th .land-hero .h1 { font-size: 36px; }
}

/* ---------- เคารพการตั้งค่าลดการเคลื่อนไหว ---------- */
@media (prefers-reduced-motion: reduce) {
  body.th *, body.th *::before, body.th *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

@media print {
  body.th .top, body.th .foot, body.th .btn, body.th .tabs, body.th .pad { display: none !important; }
  body.th .card { box-shadow: none; break-inside: avoid; }
}

/* เพิ่มเติม : การตัดสินตามเกณฑ์ในหน้าผลสอบ */
body.th .result-go { justify-content: center; }
body.th .score-judge { margin: 0 0 14px; display: grid; gap: 4px; justify-items: center; }
body.th .score-judge .sm { max-width: 46ch; }
