/* ══ ui-scale-1025 · กฎกลางขนาดหน้าต่าง + ตัวหนังสือ + ปุ่ม ทั้งเกม (design-briefs/ui-scale-1025/BRIEF.md · docs/rules/ui-touch.md) ══
   ต้นแบบ = หน้าสังคมใหม่ (ui-social.css .sx2) — ผู้ใช้ 25 ต.ค. "ตัวหนังสือใหญ่อ่านง่าย" · หน้าอื่นขยับเข้าหาทีละรอบ
   - ค่าทั้งหมดเป็นตัวแปรใต้ html.ui2 (index.html ใส่คลาสก่อนโหลด CSS) · ?ui2=0 = ไม่มีคลาส → ตัวแปรไม่ถูกตั้ง → ทุกที่ใช้ค่า fallback เดิม
   - วิธีย้ายหน้าต่าง: ในไฟล์ของหน้านั้น เขียน `font-size: var(--fs-body, 15px)` (fallback = ค่าเดิมเป๊ะ เพื่อ ?ui2=0) ห้ามเขียน px ตรง ๆ เพิ่ม
     แล้วย้ายชื่อหน้าต่างไปบรรทัด `done:` ข้างล่าง → server/ui-scale.test.js บังคับ [data-win="ชื่อ"] ไม่มี font-size px / width: min( ตรง ๆ อีก
   - ขนาดมีผลแค่คอม · จอสัมผัส (touch-ui) = Screen Shell เต็มจอเหมือนเดิม (ui-touch.css)
   - ห้าม: z-index นอกตาราง --z-* · position ตายตัวใน HUD · :has() จบด้วยแท็ก · animation forwards/infinite (perf.md 4b)

   ตารางขนาด (server/ui-scale.test.js อ่านบล็อกนี้ — ทุกชื่อหน้าต่างในโค้ดต้องอยู่ที่นี่ครบ ชื่อละครั้ง):
@ui-size-map
L: social codex guide belfry gem guild circle stamps stampalbum cheer lines status
M: packs autotgt items equip gear skills quests craft refine city market cart mystall stall shop storage job warp herald trade party rank mvp fame checkin settings community gearview gearbook trainer npc arena collector
S: passsell invite
done: social belfry guide circle quests lines
@end
   L = หน้าศูนย์รวม · M = หน้าต่างใช้งานทั่วไป · S = คำถาม/ยืนยัน/รางวัล
   gem = ร้านเพชร (#gem-shop ไม่ใช่ .win) · guild = รอ guild-1025 รวมเข้า master
   รอบ: 1 social (ปุ่ม 18/52) · 2 belfry guide circle + ร้านเพชร (gem-shop.css ย้ายแล้ว) ✓ · 2b L ที่เหลือ (codex stamps กิลด์) · 3 items/status/skills/quests · 4 M ที่เหลือ · 5 S + ป๊อปอัปยืนยัน */

html.ui2 {
  /* ตัวหนังสือ — คอมและมือถือค่าเดียวกัน */
  --fs-xs: 12px; --fs-sm: 14px; --fs-body: 16px; --fs-name: 18px; --fs-title: 20px; --fs-hero: 24px;
  /* ปุ่ม: ทั่วไป 44 (จอสัมผัส 48) · ปุ่มหลัก/ปุ่มในแถวรายชื่อ 52 · ไอคอนในปุ่ม 26 */
  --btn-h: 44px; --btn-h-main: 52px; --fs-btn: 17px; --fs-btn-main: 18px; --btn-ic: 26px;
  /* ขนาดหน้าต่าง S / M / L (คอม) */
  --win-s-w: min(92vw, 440px);
  --win-m-w: min(94vw, 820px); --win-m-h: min(88vh, 720px);
  --win-l-w: min(1580px, calc(100vw - 40px)); --win-l-h: min(800px, calc(100vh - 44px));
  /* สังคม (คอม): เดิมใช้ L เต็มจอกว้าง ใหญ่กว่าหน้าอื่นมาก — 1 พ.ย. เจ้าของ "design สวยแล้ว เหลือแค่ขนาดใหญ่เกิน" → กว้างระหว่าง M กับ L · สูงเท่า M */
  --win-social-w: min(94vw, 1080px); --win-social-h: var(--win-m-h);
  /* แต้มเชียร์ (cheer-coupon-1112 2จ รอบ 2): หน้าต่างแบบตู้ — ขนาดเดียวกับตู้กาชา cap2 (.lb-win 1080×700) ไม่ใช่ L เต็ม (แผงขวาโล่ง) */
  --win-cheer-w: min(96vw, 1080px); --win-cheer-h: min(700px, 94vh);
  /* หน้าสถานะ/จัดสรร (status-ux-1116): กราฟ + การ์ด 2×3 + ค่าที่ได้รับ 3 กลุ่ม — กว้างระหว่าง M กับ L · สูงตามเนื้อ ไม่เกินจอ */
  --win-status-w: min(96vw, 1060px); --win-status-h: min(calc(100vh - 24px), 820px);
  /* กรอบครีมแบบ social */
  --win-r-l: 28px; --win-r-l-in: 26px; --win-r-m: 22px; --win-r-s: 18px;
  --win-bg: linear-gradient(#fdf8ec, #f8efdc); --win-bd: #ead8ad; --win-bd-w: 3px;
  --win-shadow: 0 18px 50px #2a1d0e66, inset 0 0 0 2px #fffaf0;
}
html.ui2.touch-ui { --btn-h: 48px; }
/* จอเตี้ย (คอมหน้าต่างเตี้ย/แท็บเล็ตแนวนอนเล็ก): ตัวหนังสือลด 1 ขั้น — media เดียวของกฎนี้ */
@media (max-height: 420px) {
  html.ui2 { --fs-body: 14px; --fs-name: 16px; --fs-title: 18px; --fs-hero: 20px; }
}

/* ── รอบ 2: หน้าต่างขนาด L (คอม) — belfry · guide · circle (social มีกฎของตัวเองใน ui-social.css · ร้านเพชร #gem-shop อยู่ gem-shop.css) ──
   กรอบครีม/ขอบ/มุมเดียวกับ social · ปุ่ม ✕ + หัวไม้ยังอยู่ (ไม่ซ่อน header) */
html.ui2:not(.touch-ui) #windows .win[data-win="belfry"],
html.ui2:not(.touch-ui) #windows .win[data-win="guide"],
html.ui2:not(.touch-ui) #windows .win[data-win="circle"] {
  box-sizing: border-box; width: var(--win-l-w) !important; height: var(--win-l-h) !important; max-height: none !important; min-width: 0;
  display: flex; flex-direction: column; border: var(--win-bd-w) solid var(--win-bd) !important; border-radius: var(--win-r-l) !important;
  background: var(--win-bg) !important; box-shadow: var(--win-shadow) !important;
}
html.ui2:not(.touch-ui) #windows .win[data-win="guide"] > .body { height: auto !important; flex: 1 1 auto; min-height: 0; }
html.ui2:not(.touch-ui) #windows .win[data-win="guide"],
html.ui2:not(.touch-ui) #windows .win[data-win="circle"] { overflow: hidden; }

/* ── window-stable-1031: หน้าต่างที่มีแท็บ = กรอบขนาดคงที่ทุกแท็บ (client/win-stable.js WS_SIZE · ?winfix=0 = แบบเดิม) ──
   เจ้าของ 31 ต.ค. "สลับ tab แล้วจอขยับ เดี๋ยวใหญ่ขึ้น เดี๋ยวเล็กลง" · ui.makeWin ติด .ws .ws-<s|m|l> ให้หน้าต่างใน WS_SIZE
   คอม + ui2 เท่านั้น (?ui2=0 = ไม่ล็อก · จอสัมผัส = Screen Shell เต็ม Safe Area อยู่แล้ว) · เนื้อยาวเลื่อนใน .body · สั้นไม่หด · ทับขนาดเฉพาะแท็บ (แสตมป์ sfl-wide · โหมดย่อย win-salv)
   ตรวจ: node tools/check-window-stable.mjs <QA> — ขยับ ≤ 1 px ทุกแท็บ ทุกจอ */
html.ui2.winfix:not(.touch-ui) body #windows .win.ws:not([hidden]) {   /* :not([hidden]) — display:flex !important เคยทับ hidden → ปิดหน้าต่างไม่ได้ ซ้อนกันหลายบาน (เจ้าของ 1 พ.ย.) */
  box-sizing: border-box; max-width: none !important; min-height: 0 !important;   /* max-height เดิมของบาน (เช่น เว้นช่องลัดล่างจอ) คงไว้ — เท่ากันทุกแท็บอยู่แล้ว */
  display: flex !important; flex-direction: column;
}
html.ui2.winfix:not(.touch-ui) body #windows .win.ws-m { width: var(--win-m-w) !important; height: var(--win-m-h) !important; }
html.ui2.winfix:not(.touch-ui) body #windows .win.ws-l { width: var(--win-l-w) !important; height: var(--win-l-h) !important; }
html.ui2.winfix:not(.touch-ui) body #windows .win.ws-mh { height: var(--win-m-h) !important; }
html.ui2.winfix:not(.touch-ui) body #windows .win.ws-lh { height: var(--win-l-h) !important; }
html.ui2.winfix:not(.touch-ui) body #windows .win.ws > header,
html.ui2.winfix:not(.touch-ui) body #windows .win.ws > .foot { flex: none; }
html.ui2.winfix:not(.touch-ui) body #windows .win.ws > .body { flex: 1 1 auto; min-height: 0; height: auto !important; max-height: none !important; overflow: auto; }
/* กระเป๋า (คอม): แท็บหมวดแถวเดียวเต็มกว้าง (เดิมตาราง 5 ช่อง 2 แถวในกรอบ 340) */
html.ui2.winfix:not(.touch-ui) body #windows .win.ws[data-win="items"] .inv > .vtabs { display: flex !important; flex-wrap: nowrap; }
html.ui2.winfix:not(.touch-ui) body #windows .win.ws[data-win="items"] .inv > .vtabs > [data-tab] { flex: 1 1 0; }
html.ui2.winfix:not(.touch-ui) body #windows .win.ws[data-win="items"] .inv > .vtabs > .bag-salv { flex: none; }
/* สกิล | คัมภีร์: แท็บสกิลวางแถบหัวชิดขอบ .body (skw-on · padding 0) · แท็บคัมภีร์แปะแถบเดียวกันใน .body ที่มี padding → แถบเลื่อน 8 px แคบลง 16 px
   winfix: แท็บคัมภีร์ดึงแถบออกไปชิดขอบเท่าแท็บสกิล (คอม + จอสัมผัส) */
html.ui2.winfix body #windows .win[data-win="skills"]:not(.skw-on) > .body { padding: 10px !important; }
html.ui2.winfix body #windows .win[data-win="skills"]:not(.skw-on) > .body > .skw-tabs { margin: -10px -10px 8px !important; }
/* หน้าแปะแสตมป์ (stamps · stamp-dnd): สามแท็บสามโครง — แถบแท็บต่างที่ต่างขนาด
   แปะ (คอม/จอสัมผัส): แถบในคอลัมน์ซ้าย 250 (จอสัมผัส สองแถว) · คอมโบ (จอสัมผัส): แถบกว้างตามปุ่ม มีหัวอัลบั้มต่อขวา · คลัง: กรอบ .spg-cst เว้น 8 px → แถบหดเข้า
   winfix: แถบเต็มแถวบนสุด ที่เดียวกันทุกแท็บ (ส่วนอื่นของแต่ละแท็บไม่แตะ) */
html.ui2.winfix body #windows .win[data-win="stamps"] .spg:not(.spg-alb) { grid-template-areas: "tabs tabs" "side main" "sheet sheet"; }
html.ui2.winfix.touch-ui body #windows .win[data-win="stamps"] .spg:not(.spg-alb) { grid-template-rows: auto minmax(0, 1fr) auto; }
html.ui2.winfix body #windows .win[data-win="stamps"] .spg:not(.spg-alb) > .spg-main { grid-row: 2 !important; }   /* .has-cmb เดิมยืดขึ้นแถวแท็บ (1 / span 2) ทับแถบ */
html.ui2.winfix body #windows .win[data-win="stamps"] .spg.spg-alb > .spg-tabs { flex: 1 1 100%; }
html.ui2.winfix body #windows .win[data-win="stamps"] .spg-cst > .spg-tabs { margin-inline: -8px; }
html.ui2.winfix body #windows .win[data-win="stamps"] .spg-tabs { flex-wrap: nowrap; }
/* จอสัมผัสกว้าง ≥ 900 (iPad): แผ่นรวม ตัวละคร|กระเป๋า — แท็บสวมใส่ติด .gear-equip กว้าง 800 (ui-equip.css) ทับ Screen Shell → กรอบแคบกว่าแท็บกระเป๋า
   winfix: เต็ม Safe Area เท่ากันทุกแท็บ (ซ้าย/ขวาจาก Screen Shell) */
html.ui2.winfix.touch-ui body #windows .win.gear-equip.gear-equip[data-win]:not([hidden]) { width: auto !important; }
