/* หน้าต่างเปลี่ยนอาชีพกับ Rowan (job-window.js)
   สี: ครีม #f3e6c8 · ทีล #2f6f73 (เลือก/นำทาง) · ทอง #e8b64a (ปุ่มหลัก/ฉลอง ใช้พอประมาณ) · น้ำตาล #8a5a32 · ตัวหนังสือ #342c26
   ⚠️ ตัวหนังสือไม่ต่ำกว่า 13px · อาชีพที่ยังเปลี่ยนไม่ได้ต้องอ่านออกครบ (จางแค่นิด) ไม่หาย */

#windows .win[data-win="job"] { box-sizing: border-box; width: min(94vw, 880px); height: min(88vh, 680px); max-height: none; display: flex; flex-direction: column; }
html[data-skin="wood"] body .win[data-win="job"] > .body { max-height: none; }
#windows .win[data-win="job"] > .body { padding: 0; overflow: hidden; flex: 1; min-height: 0; display: flex; }
#windows .win.job-win > header { min-height: 56px; }
#windows .win.job-win header .win-ic, #windows .win.job-win header .win-ic img { width: 46px; height: 46px; }
#windows .win.job-win header .win-ic img { border-radius: 12px; border: 2px solid #e8b64a; background: #f3e6c8; object-fit: cover; object-position: top; }
#windows .win.job-win header > span { display: grid; line-height: 1.15; }
#windows .win.job-win header > span b { font: 800 18px/1.15 var(--font-head); }
#windows .win.job-win header > span small { font: 600 13px/1.2 var(--font); opacity: .8; }

#windows .job { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; color: #342c26; font-size: 14px; }
#windows .job-ic { width: 44px; height: 44px; object-fit: contain; flex: none; }

/* ── บน: บทพูด + ความคืบหน้า Job Lv ─────────────────────────── */
#windows .job-top { display: grid; gap: 8px; padding: 10px 16px; background: linear-gradient(90deg, #f6ead0, #fbf4e2); border-bottom: 1px solid #e3d2a8; }
#windows .job-say { margin: 0; font-size: 14px; color: #5b4a36; }
#windows .job-say b { color: #8a5a32; }
#windows .job-prog { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; }
#windows .job-prog b { color: #2f6f73; }
#windows .job-bar { position: relative; flex: 1; min-width: 160px; height: 22px; border-radius: 999px; background: #e7dcc2; box-shadow: inset 0 1px 2px #0002; overflow: hidden; }
#windows .job-bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #3f8a8e, #2f6f73); border-radius: 999px; }
#windows .job-bar em { position: relative; display: block; text-align: center; font: 700 13px/22px var(--font-head); font-style: normal; color: #fff; text-shadow: 0 1px 1px #0006; }
#windows .job-prog-txt { font-weight: 700; color: #8a5a32; }
#windows .job-prog-txt.ok { color: #2c7a3c; }

#windows .job-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(230px, 30%) minmax(0, 1fr); }

/* ── ซ้าย: การ์ดอาชีพ ───────────────────────────────────────── */
#windows .job-list { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 10px 12px 14px; background: #fbf5e7; border-right: 1px solid #e3d2a8; }
#windows .job-list h4 { margin: 0 0 2px; font: 700 15px/1.3 var(--font-head); color: #2f6f73; }
#windows .job-list h4 small { font: 400 13px/1 var(--font); color: #8a7a60; }
#windows .job-card { flex: none; position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: center; min-height: 72px;
  padding: 8px 10px; border-radius: 12px; border: 2px solid transparent; background: #fffdf7; box-shadow: 0 1px 0 #e7d8b4; text-align: left; font: inherit; color: inherit; cursor: pointer; }
#windows .job-card:hover { background: #fff8e6; }
#windows .job-card.sel { border-color: #2f6f73; background: #eef6f5; box-shadow: 0 2px 6px #2f6f7333; }
#windows .job-card.sel::after { content: ''; position: absolute; right: 8px; top: 8px; width: 8px; height: 8px; border-radius: 50%; background: #e8b64a; }
#windows .job-card.locked .job-ic { filter: saturate(.7); opacity: .85; }
#windows .job-card span { display: grid; gap: 1px; min-width: 0; }
#windows .job-card b { font: 700 16px/1.2 var(--font-head); }
#windows .job-card small { font-size: 13px; color: #2f6f73; font-weight: 600; }
#windows .job-card em { font-style: normal; font-size: 13px; color: #6b5a44; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── ขวา: รายละเอียด ─────────────────────────────────────────── */
#windows .job-detail { min-height: 0; display: flex; flex-direction: column; background: #fffaf0; }
#windows .jd-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 18px 8px; display: flex; flex-direction: column; gap: 10px; }
#windows .jd-back { display: none; }
#windows .jd-title { display: flex; align-items: center; gap: 10px; }
#windows .jd-title b { display: block; font: 800 22px/1.15 var(--font-head); }
#windows .jd-title span { font-size: 14px; color: #2f6f73; font-weight: 600; }
#windows .jd-desc { margin: 0; font-size: 14px; line-height: 1.5; color: #4a3f33; }
#windows .jd-hero { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
#windows .jd-hero figure { margin: 0; display: grid; grid-template-rows: 1fr auto; border-radius: 14px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 88%, #e2d3ad 0 26%, transparent 27%), linear-gradient(#f4ecda, #eadcbc); box-shadow: inset 0 0 0 1px #d8c595; }
#windows .jd-hero .jd-new { box-shadow: inset 0 0 0 2px #2f6f73; }
#windows .jd-stage { height: 170px; }
#windows .jd-stage canvas { width: 100% !important; height: 100% !important; display: block; }
#windows .jd-hero figcaption { padding: 2px 8px 6px; text-align: center; font-size: 13px; color: #7a6a52; }
#windows .jd-hero figcaption b { color: #342c26; }
#windows .jd-arrow { font: 800 26px/1 var(--font-head); color: #e8b64a; }
#windows .jd-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#windows .jd-sec h5 { margin: 0 0 4px; font: 700 14px/1.3 var(--font-head); color: #2f6f73; }
#windows .jd-ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.5; }
#windows .jd-ul li::marker { color: #2f6f73; }
#windows .jd-ul.neg li::marker { color: #b08a5a; }
#windows .jd-facts { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; }
#windows .jd-facts i { font-style: normal; color: #7a6a52; margin-right: 4px; }
#windows .jd-skills { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#windows .jd-skills li { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 8px; align-items: center; padding: 6px 8px; border-radius: 10px; background: #f6eedb; }
#windows .jd-skills img { width: 36px; height: 36px; border-radius: 8px; }
#windows .jd-skills b { display: block; font: 700 14px/1.2 var(--font-head); }
#windows .jd-skills small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; line-height: 1.35; color: #6b5a44; }

#windows .jd-foot { flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: end; padding: 10px 18px 14px; border-top: 1px solid #e3d2a8; background: linear-gradient(#fbf3df, #f6e8c8); }
#windows .jd-req h5 { margin: 0 0 4px; font: 700 14px/1.3 var(--font-head); color: #2f6f73; }
#windows .jd-req ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 14px; font-weight: 700; color: #8a5a32; }
#windows .jd-req li.ok { color: #2c7a3c; }
#windows .jd-req li small { font-weight: 400; color: #7a6a52; font-size: 13px; }
#windows .jd-req li em { display: block; font-style: normal; font-weight: 400; font-size: 13px; color: #6b5a44; }
#windows .jd-act { display: grid; gap: 4px; justify-items: end; text-align: right; }
#windows .jd-act small { font-size: 13px; color: #7a6a52; }
#windows .jd-cta { min-width: 220px; height: 50px; padding: 0 18px; border-radius: 12px; border: 1px solid #b07a1c; cursor: pointer;
  background: linear-gradient(#f8d677, #e8b64a 55%, #d99a26); color: #3e2a0c; font: 800 18px/1 var(--font-head); box-shadow: inset 0 -3px 0 #0002, 0 3px 8px #b0741a44; }
#windows .jd-cta:hover:not([disabled]) { filter: brightness(1.05); }
#windows .jd-cta:active:not([disabled]) { transform: translateY(1px); }
#windows .jd-cta[disabled] { cursor: not-allowed; background: #e4dccb; border-color: #cdbf9f; color: #7a6a52; box-shadow: none; }
#windows .jd-cta.sm { min-width: 120px; height: 44px; font-size: 17px; }
#windows .jd-err { margin: 0; padding: 6px 10px; border-radius: 8px; background: #f7e4dc; color: #8a3a2a; font-size: 14px; font-weight: 600; }
#windows .jd-muted { color: #8a7a60; font-size: 14px; }
#windows .job-test { display: flex; gap: 8px; align-items: center; padding: 6px 16px; border-top: 1px dashed #d8c595; font-size: 13px; color: #a8483a; }
/* บริการรีเซ็ตสเตตัส/สกิล (ครั้งละ 500 Gold) — แถบล่างของหน้า Rowan */
#windows .job-svc { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 16px; border-top: 1px dashed #d8c595; font-size: 13px; color: #6b5a44; }
#windows .job-svc > span { font-weight: 700; margin-right: auto; }
#windows .job-svc .rbtn small { margin-left: 4px; font-weight: 700; color: #a8783a; }
#windows .job-maxed { display: flex; gap: 16px; align-items: flex-start; padding: 24px; }
#windows .job-maxed .job-ic { width: 72px; height: 72px; }
#windows .job-maxed b { font: 800 22px/1.2 var(--font-head); }

/* ── หน้ายืนยัน / หน้าฉลอง ─────────────────────────────────────── */
#windows .job-modal { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: #2b200f66; }
#windows .job-modal[hidden] { display: none; }
#windows .job-dlg { position: relative; width: min(460px, 92%); max-height: 94%; overflow: auto; display: grid; gap: 10px; padding: 18px 20px; border-radius: 16px; background: #fffaf0; border: 2px solid #e8b64a; box-shadow: 0 14px 40px #0005; }
#windows .job-dlg h4 { margin: 0; font: 800 19px/1.2 var(--font-head); color: #5a3a12; }
#windows .jc-flow { display: flex; align-items: center; justify-content: center; gap: 10px; font: 700 16px/1.2 var(--font-head); }
#windows .jc-flow b { color: #e8b64a; font-size: 22px; }
#windows .jc-flow .to { color: #2f6f73; }
#windows .jc-unlock { margin: 0; font-size: 14px; color: #2f6f73; font-weight: 600; text-align: center; }
#windows .jc-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
#windows .jc-list dt { font-weight: 700; color: #6b5a44; white-space: nowrap; }
#windows .jc-list dd { margin: 0; line-height: 1.45; }
#windows .jc-warn { margin: 0; padding: 8px 12px; border-radius: 10px; background: #f7e4dc; color: #8a3a2a; font-weight: 700; font-size: 14px; text-align: center; }
#windows .jc-a { display: flex; justify-content: flex-end; gap: 8px; }
#windows .jc-a .rbtn { min-height: 44px; padding: 0 16px; font-size: 15px; }
#windows .job-win-dlg { text-align: center; justify-items: center; overflow: hidden; }
#windows .job-win-dlg h4 { font-size: 22px; color: #2f6f73; }
#windows .job-win-dlg p { margin: 0; font-size: 14px; color: #5b4a36; }
#windows .jw-emblem { width: 96px; height: 96px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle, #fff6d8, #f2d58a); box-shadow: 0 0 0 3px #e8b64a, 0 0 28px #e8b64aaa; animation: jwPop .5s cubic-bezier(.2, 1.4, .4, 1) both; }
#windows .jw-emblem .job-ic { width: 70px; height: 70px; }
#windows .jw-name { font: 800 26px/1.1 var(--font-head); letter-spacing: .06em; color: #342c26; text-transform: uppercase; }
#windows .jw-tag { font-weight: 600; color: #2f6f73 !important; }
#windows .jw-note { font-size: 13px !important; color: #7a6a52 !important; }
#windows .jw-burst { position: absolute; inset: -40%; pointer-events: none; background: conic-gradient(from 0deg, #e8b64a22 0 8%, transparent 8% 16%, #e8b64a22 16% 24%, transparent 24% 32%, #e8b64a22 32% 40%, transparent 40% 48%, #e8b64a22 48% 56%, transparent 56% 64%, #e8b64a22 64% 72%, transparent 72% 80%, #e8b64a22 80% 88%, transparent 88%);
  animation: jwSpin 6s linear infinite, jwFade .6s ease-out both; }
#windows .job-win-dlg > :not(.jw-burst) { position: relative; }
@keyframes jwPop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes jwSpin { to { transform: rotate(360deg); } }
@keyframes jwFade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #windows .jw-burst, #windows .jw-emblem { animation: none; } }

/* จอคอมเตี้ย */
@media (max-height: 820px) { #windows .jd-stage { height: 130px; } #windows .job-card { min-height: 62px; } }

/* ═══ มือถือ ═══ */
html.touch-ui #windows .job-card { min-height: 64px; }
html.touch-ui #windows .jd-cta { height: 50px; }
/* แนวตั้ง: การ์ดอาชีพ → แตะ → รายละเอียด (ปุ่มกลับ) · แผ่นล่างเกือบเต็มจอ */

/* แนวนอน: เต็มความกว้าง สองคอลัมน์ · ตัดบทพูดออก (จอเตี้ย) */
html.touch-ui.land #windows .win[data-win="job"] { left: max(6px, env(safe-area-inset-left)) !important; right: max(6px, env(safe-area-inset-right)); width: auto !important; height: auto; }
html.touch-ui.land #windows .job-say { display: none; }
html.touch-ui.land #windows .job-top { padding: 6px 12px; }
html.touch-ui.land #windows .jd-stage { height: 110px; }
html.touch-ui.land #windows .jd-foot { padding: 6px 12px 8px; }
/* แนวนอน (สูง ~360px): ตัดคำบรรยายยาวกับหัวรายการ · ตัวละครเทียบวางถัดจากชื่อ ไม่ต้องเลื่อนถึงจะเห็น */
html.touch-ui.land #windows .jd-desc, html.touch-ui.land #windows .job-list h4 { display: none; }
html.touch-ui.land #windows .jd-scroll { padding: 6px 12px; gap: 6px; }
html.touch-ui.land #windows .jd-title b { font-size: 18px; }
html.touch-ui.land #windows .jd-title .job-ic { width: 34px; height: 34px; }
html.touch-ui.land #windows .jd-hero figcaption { padding: 0 6px 4px; }
html.touch-ui.land #windows .job-card { min-height: 56px; padding: 6px 8px; }
html.touch-ui.land #windows .job-card em { display: none; }
html.touch-ui.land #windows .job-dlg { padding: 12px 16px; gap: 6px; }
html.touch-ui.land #windows .jc-list { gap: 3px 10px; font-size: 13px; }
/* ปุ่มยกเลิก/ยืนยันติดขอบล่างของหน้ายืนยันเสมอ (จอเตี้ยต้องเลื่อนอ่านผล แต่ปุ่มต้องเห็นตลอด) */
#windows .job-dlg .jc-a { position: sticky; bottom: -18px; margin: 0 -20px -18px; padding: 10px 20px 14px; background: linear-gradient(#fffaf000, #fffaf0 30%); }
html.touch-ui.land #windows .job-dlg .jc-a { bottom: -12px; margin: 0 -16px -12px; padding: 8px 16px 10px; }
/* ป้ายบททดสอบบนการ์ดอาชีพ */
#windows .job-card .job-trial-bd { position: absolute; right: 8px; bottom: 6px; font-style: normal; font-size: 13px; font-weight: 700; padding: 0 8px; border-radius: 999px; background: #fdf0d2; color: #8a5a32; }
#windows .job-card .job-trial-bd.ok { background: #e3f1e5; color: #2c7a3c; }
#windows .job-card .job-trial-bd { position: static; grid-column: 2; justify-self: start; margin-top: -2px; }
