/* Bước 4 "Phân tích mẫu" (mã bước 6, js/buoc_mau.js) — giao diện theo mock up D:\big\mockups\phan-tich-mau-trang4 (2026-11-04).
 * 1 trang dài: thanh 3 phần dính trên cùng; mỗi phần trái = ảnh (dính khi cuộn), phải = nội dung. Lớp có tiền tố pm-. */
#mauStepContainer.pm {
  --line: #dfe8e9; --muted: #607580; --ink: #142b38; --c4: #0891b2; --c4s: #e3f6fa;
  --top: 52px; --bar: 50px;
  color: var(--ink); font: 13px/1.4 'Be Vietnam Pro', system-ui, sans-serif; padding-bottom: 12px;
}
#mauStepContainer.pm * { box-sizing: border-box; }
#mauStepContainer.pm button { font: inherit; cursor: pointer; }
#mauStepContainer.pm [hidden] { display: none !important; }

/* thanh 3 phần */
.pm-phan { position: sticky; top: var(--top); z-index: 20; margin: 0 -8px 8px; padding: 8px 8px 0; background: #f5f8f8; }
.pm-phan > div { height: 42px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.pm-phan button { border: 0; background: transparent; border-radius: 9px; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; font-size: 13px; color: #5b6f78; min-width: 0; white-space: nowrap; overflow: hidden; }
.pm-phan button b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; font-size: 11px; background: #fff; border: 1.5px solid #d3dfe0; color: #8a9a9f; }
.pm-phan button.on { background: var(--c4s); color: var(--c4); }
.pm-phan button.on b { background: var(--c4); border-color: var(--c4); color: #fff; }

/* phần */
/* Mỗi phần cao đúng 1 màn hình: ảnh trái đứng yên, cột phải tự cuộn; cuộn hết cột phải mới sang phần sau
 * (lăn chuột trên ảnh cũng cuộn cột phải — buoc_mau.js). Trang dừng đúng đầu mỗi phần (html.pm-cuonKhuc). */
.pm-sec { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 8px; margin-bottom: 10px; scroll-margin-top: calc(var(--top) + var(--bar) + 8px);
  height: calc(100vh - var(--top) - var(--bar) - 18px); scroll-snap-align: start; }
html.pm-cuonKhuc { scroll-snap-type: y mandatory; }   /* chỗ dừng = scroll-margin-top của .pm-sec (đừng thêm scroll-padding: cộng 2 lần) */
html.pm-cuonKhuc #mauStepContainer.pm { padding-bottom: calc(var(--top) + var(--bar) + 30px); }   /* phần 3 (cuối) cũng cuộn được lên sát đầu */
html.pm-khoaCuon { overflow: hidden; }
/* phần 1: ảnh ~3/4 lần trước; phần 2: ảnh bớt 1/3; phần 3: 3 ảnh đối chiếu */
#pmS1 { grid-template-columns: minmax(0, 9fr) minmax(420px, 17fr); }
#pmS2 { grid-template-columns: minmax(0, 6fr) minmax(420px, 7fr); }
#pmS3 { grid-template-columns: minmax(0, 7fr) minmax(420px, 6fr); }
.pm-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.pm-left { height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pm-right { padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; height: 100%; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.pm-right > * { flex: 0 0 auto; }
.pm-right h2 { margin: 0; font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.pm-right h2 b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: var(--c4); color: #fff; }
.pm-right h4 { margin: 6px 0 0; font-size: 13.5px; font-weight: 800; color: var(--c4); }

/* đầu khung ảnh: chọn hàm, nguồn ảnh */
.pm-lhead { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pm-lhead .r { margin-left: auto; }
.pm-seg { display: inline-flex; background: #f3f7f7; border: 1px solid var(--line); border-radius: 10px; padding: 2px; gap: 2px; }
.pm-seg button { border: 0; background: transparent; border-radius: 8px; padding: 5px 11px; font-weight: 700; font-size: 12.5px; color: #5b6f78; }
.pm-seg button.on { background: #fff; color: var(--c4); box-shadow: 0 1px 4px rgba(20,60,70,.12), inset 0 0 0 1.5px var(--c4); }

/* ảnh */
.pm-stage { position: relative; flex: 1; min-height: 0; background: radial-gradient(ellipse at 50% 45%, #3b2a27 0%, #1c1513 60%, #0f0b0a 100%); overflow: hidden; }
.pm-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
/* khung ảnh chung phần 1 / 2 (#ptmBan chuyển giữa 2 chỗ .pm-cho); nút riêng của từng phần: .chi1 / .chi2 */
.pm-cho, .pm-ban { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#mauStepContainer.p2 .chi1, #mauStepContainer:not(.p2) .chi2 { display: none !important; }
.pm-tick { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 12.5px; color: #38505b; cursor: pointer; }
.pm-tick input { accent-color: var(--c4); width: 15px; height: 15px; margin: 0; }
.ptm-diem { padding: 5px 10px; border-bottom: 1px solid var(--line); background: #fffbea; font-size: 12.5px; color: #38505b; line-height: 1.6; }
.ptm-diem .nho { color: var(--muted); font-size: 12px; }
.ptm-diem .nghi { color: #b45309; font-weight: 700; }
.ptm-diem .nut-phu { height: 24px; margin-left: 4px; border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 0 8px; font-weight: 700; font-size: 12px; color: #38505b; }
.ptm-diem .nut-phu:hover { border-color: #9cc9c4; }
/* phần 2: 6 ảnh (hàng trên trong miệng, hàng dưới mẫu hàm; phải / thẳng / trái); bấm 1 ảnh = phóng to để sửa */
.pm-luoi { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 6px; align-content: start; }
.pm .pm-o5 { position: relative; aspect-ratio: 4 / 3; padding: 0; border: 1.5px solid var(--line); border-radius: 9px; overflow: hidden; background: #1d2a2e; }
.pm .pm-tb.r { margin-left: auto; }
.pm-o5 canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pm-o5 span { position: absolute; left: 6px; top: 4px; font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
.pm-o5 em { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font-style: normal; font-size: 12px; font-weight: 700; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.8)); text-align: left; }
.pm .pm-o5:hover:not(:disabled) { border-color: var(--c4); box-shadow: 0 0 0 2px var(--c4); }
.pm .pm-o5.dung { border-color: #7cc7d6; }
.pm .pm-o5:disabled { background: #f3f7f7; cursor: default; }
.pm-o5:disabled span { color: #94a3b8; text-shadow: none; }
.pm-o5:disabled em { color: #94a3b8; background: none; }
.pm .pm-tb.bat { background: var(--c4s); border-color: var(--c4); color: var(--c4); }
/* phần 3: ảnh cười (đường giữa mặt) | ảnh cắn thẳng (đường giữa HT / HD), pano 3 thanh ở dưới — vừa 1 màn hình */
.pm-g3 { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 6px; padding: 6px; }
.pm .pm-g3 .pm-o5 { aspect-ratio: auto; height: 100%; }
.pm-mat { position: relative; min-height: 0; background: #1d2a2e; border-radius: 9px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pm-mat .pm-stage.trong { position: absolute; inset: 0; }
.pm-matk { position: relative; flex: 0 0 auto; cursor: zoom-in; touch-action: none; user-select: none; }
.pm-matTo .pm-matk { cursor: default; }
.pm-matk img { display: block; width: 100%; height: 100%; }
/* vạch đường giữa mặt: mảnh, trong suốt; vùng bắt chuột 22 px hai bên (hút chuột) */
.pm-gmat { position: absolute; top: 0; bottom: 0; width: 22px; transform: translateX(-50%); cursor: ew-resize; }
.pm-gmat::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; transform: translateX(-50%); background: rgba(34,211,238,.55); }
.pm-gmat:hover::before, .pm-matk.keo .pm-gmat::before { width: 2px; background: rgba(34,211,238,.95); box-shadow: 0 0 6px rgba(34,211,238,.9); }
.pm-pano { grid-column: 1 / -1; }
.pm-pano > div { margin-top: 0 !important; padding: 6px 8px !important; }
.pm-pano img { max-height: 27vh !important; }
/* ảnh phóng to giữa màn hình (~2/3): bấm nền tối = đóng */
.pm-phong { position: fixed; inset: 0; z-index: 900; background: rgba(15,23,42,.62); display: flex; align-items: center; justify-content: center; }
.pm-phong[hidden] { display: none !important; }
.pm-phongk { position: relative; width: min(1180px, 68vw); height: 72vh; background: #fff; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.pm-phong[data-loai="khop"] .pm-matTo, .pm-phong[data-loai="mat"] .pm-cho { display: none; }
.pm-matTo { flex: 1; border-radius: 0; }
.pm .pm-phongX { position: absolute; right: 8px; top: 8px; z-index: 3; width: 30px; height: 30px; border: 0; border-radius: 8px; background: #f1f5f9; font-size: 15px; }
.pm-phong[data-loai="khop"] .pm-cong { padding-right: 46px; }
.pm .cc-ta input[type=text] { padding: 4px 6px; font: inherit; font-size: .75rem; height: 27px; border-radius: 4px; border: 1px solid #cbd5e1; width: 100%; }
.pm-gm { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 12.5px; }
.pm-gm > div { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; color: #475569; font-weight: 600; }
.pm-gm > div b { color: var(--ink); }
.pm-gm > .kq { border-top: 1px dashed var(--line); margin-top: 2px; padding-top: 4px; }
.pm-gm > .kq b { color: var(--c4); font-size: 13.5px; }
/* phần 1: điều chỉnh dây cung ngay dưới ảnh */
.pm-dc { padding: 6px 12px 8px; border-top: 1px solid var(--line); }
.pm-dch { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.pm-dch .r { margin-left: auto; }
.pm-dcg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin-top: 4px; }
.pm-dcg .pm-thanh { margin: 0; font-size: 12px; }
.pm-dcg .pm-thanh input { margin-top: 0; }
/* nút Nhổ răng (sau Mô phỏng xếp răng): ô đóng khung màu đỏ nhạt */
.pm .pm-nhoNut { height: 28px; padding: 0 12px; border: 1.5px solid #f87171; border-radius: 8px; background: #fef2f2; color: #b91c1c; font-weight: 800; font-size: 12.5px; }
.pm .pm-nhoNut:hover { background: #fee2e2; }
/* "Hiển thị thước đo" R6-6: nút ngay sau tên mục */
.pm .cc-h .pm-tick { font-size: 12px; margin-left: auto; }
.pm .cc-h .pm-nb { margin-left: 6px; height: 24px; }
.pm .cc-h.sau { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
.pm .cc-h.sau .pm-tick { margin-left: 0; }
.pm .cc-h.sau .pm-nb { margin-left: 0; }
.pm .cc-h .pm-nutThuoc { padding: 2px 10px 2px 7px; border: 1.5px solid var(--c4); border-radius: 999px; background: var(--c4s); color: var(--c4); font-size: 11.5px; }
.pm .cc-h .pm-nutThuoc input { width: 13px; height: 13px; accent-color: var(--c4); }
.pm .cc-h .pm-nutThuoc:has(input:checked) { background: var(--c4); color: #fff; }
.pm .cc-h .pm-tuDien { font-style: normal; font-weight: 700; color: #dc2626; font-size: .74rem; }
/* AI điền: chữ cam cạnh tên mục + nút / ô chữ cam (khác đỏ "Bác sĩ cần tự điền"); bác sĩ chọn lại → xanh như thường */
.pm .pm-aiDien { font-style: normal; font-weight: 800; color: #ea580c; font-size: .7rem; margin-left: 4px; }
.pm .cc-h .pm-aiDien { margin-left: 0; }
.pm .opt-chip.selected.ai { background: #f97316; border-color: #f97316; box-shadow: 0 1px 3px rgba(249,115,22,.3); }
.pm textarea.ai, .pm .pm-mm.ai { color: #c2410c; font-weight: 700; border-color: #fdba74; }
.pm #pmKhop .btn-tooth-chip.selected.nghi { background: #f97316; border-color: #f97316; color: #fff; }
/* bảng số: ô tự gõ + ✓ */
.pm-ho input { width: 52px; height: 24px; border: 1px solid #cbd5e1; border-radius: 7px; padding: 0 6px; font: inherit; font-size: 12px; }
.pm .pm-ho button.ok { width: 26px; background: var(--c4); border-color: var(--c4); color: #fff; }
/* ảnh phóng to (ảnh cười / ảnh cắn thẳng mở từ phần 3): menu điền đường giữa bên phải, 2 menu trình bày giống nhau */
.pm-phong[data-menu] .pm-phongk { flex-direction: row; width: min(1300px, 80vw); }
.pm-phong[data-menu] .pm-cho, .pm-phong[data-menu] .pm-matTo { min-width: 0; }
.pm-phongMenu { display: none; }
.pm-phong[data-menu] .pm-phongMenu { order: 2; display: flex; flex-direction: column; gap: 12px; flex: 0 0 300px; padding: 14px 14px 16px; border-left: 1px solid var(--line); background: #f8fafc; overflow: auto; }
.pm-phong[data-menu] .pm-phongX { right: 12px; top: 10px; }
.pm-menuT { font-size: 15px; font-weight: 800; color: var(--ink); padding: 4px 40px 8px 2px; border-bottom: 1px solid var(--line); }
.pm-menuThe { flex: 1; }
.pm .pm-phongMenu .criterion-card { margin: 0; padding: 12px; border-radius: 12px; box-shadow: 0 2px 10px rgba(15,23,42,.07); }
.pm .pm-phongMenu .cc-h { line-height: 1.35; margin-bottom: 10px; }
.pm .pm-phongMenu .cc-h span { font-size: .92rem; }
.pm .pm-phongMenu .opt-chips-wrap { flex-direction: column; align-items: stretch; gap: 8px; }
.pm .pm-phongMenu .opt-chip { text-align: left; padding: 9px 14px !important; font-size: .9rem !important; border-radius: 10px !important; }   /* style.css .opt-chip có !important */
.pm .pm-menuXong { height: 38px; border: 0; border-radius: 10px; background: var(--c4); color: #fff; font-weight: 800; font-size: 14px; }
/* phần 1: 3 nhóm (chen chúc + khe thưa | độ rộng R6-6 | cân xứng HT + HD) — trong nhóm sát, giữa nhóm xa */
#pmS1 .pm-right { gap: 9px; }
.pm-nhom { display: flex; flex-direction: column; gap: 4px; }
.pm-nhom + .pm-nhom { margin-top: 8px; }
.pm .pm-tu input.ai { color: #c2410c; font-weight: 700; border-color: #fdba74; }
/* khớp cắn: các mục sát nhau */
.pm #pmKhop.pm-dsk { gap: 4px; }
.pm #pmKhop .criterion-card { padding: 4px 8px; }
.pm #pmKhop .cc-h { margin-bottom: 2px; }
.pm #pmKhop .opt-chips-wrap { gap: 3px; margin-bottom: 2px; }
.pm #pmKhop .cc-ta { margin-top: 0; }
.pm #pmKhop .p5-pair-card { padding: 4px 8px 2px; }
.pm #pmKhop .p5-pair-title { margin-bottom: 2px; }
.pm #pmKhop .p5-pair > .p5-side { padding: 1px 6px 2px 0; }
/* phần 3: kết luận đường giữa + hình Slide 8 thu nhỏ */
.pm-ketLuan { border: 1.5px solid var(--c4); border-radius: 12px; background: #f0fbfd; padding: 6px 10px 8px; }
.pm-klT { font-size: 12px; font-weight: 800; color: var(--c4); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 2px; }
.pm-ketLuan .pm-gm { border: 0; padding: 0; background: none; font-size: 13px; }
.pm-ketLuan .pm-gm > .kq b { font-size: 14px; }
.pm-s8 svg { display: block; width: 100%; max-width: 300px; margin: 6px auto 0; font-family: Arial, sans-serif; }
.pm-s8 .khung { fill: #fff; stroke: #000; stroke-width: 2.5; }
.pm-s8 .o { fill: #fff; stroke: #000; stroke-width: 1.2; }
.pm-s8 .truc { stroke: #000; stroke-width: 2; }
.pm-s8 .ngang { stroke: #000; stroke-width: 2.5; }
.pm-s8 text { text-anchor: middle; fill: #000; }
.pm-s8 .tieu { font-size: 13.5px; font-weight: 900; }
.pm-s8 .nhan { font-size: 12px; font-weight: 600; }
.pm-s8 .nho { font-size: 10.5px; font-weight: 600; }
.pm-s8 .so { font-family: 'Times New Roman', serif; font-size: 16px; font-weight: 700; }
/* "Xoay ảnh": góc phải đầu khung ảnh phần 1 */
.pm-xoayCho { margin-left: auto; display: flex; align-items: center; }
.pm .pm-goc .pm-xoayTen { font-size: 11.5px; font-weight: 700; color: var(--muted); margin-right: 2px; }
.pm .pm-xoayCho .pm-goc .pm-tb { height: 28px; }
/* thẻ khớp cắn gọn: ô số ngay sau các nút */
.pm .pm-gon .opt-chips-wrap { align-items: center; margin-bottom: 0; }
.pm .pm-mm { width: 92px; height: 22px; padding: 0 8px; border: 1px solid #cbd5e1; border-radius: 999px; font: inherit; font-size: .74rem; }
/* bảng chọn độ cắn hở cạnh chuột */
.pm-ho { position: fixed; z-index: 1000; display: flex; gap: 4px; padding: 5px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(15,23,42,.18); }
.pm .pm-ho button { width: 32px; height: 24px; border: 1px solid #cbd5e1; border-radius: 7px; background: #fff; font-size: 12px; font-weight: 800; color: #334155; }
.pm .pm-ho button:hover { border-color: #059669; background: #ecfdf5; color: #047857; }
/* thước đo của lõi: đo xong bấm ra ngoài ảnh = tắt (ẩn ô số, nút về "Thước đo"); đường thước vẫn trên ảnh */
/* (phần 1 ô thước nằm ở cột công cụ, ngoài #ptmBan → :has; chữ nút về "Thước đo" do ptmNut) */
.pm:has(#ptmBan.thuocTat) #ptm_thuocO { display: none !important; }
.pm-stage > span { position: absolute; left: 8px; top: 6px; font-size: 11.5px; font-weight: 800; color: rgba(255,255,255,.8); z-index: 1; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.pm-stage.trong::after { content: 'Chưa có ảnh'; position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.45); font-weight: 700; font-size: 12.5px; }

/* ô tổng thừa / thiếu khoảng: tên hàm + nhãn tổng (màu theo thiếu / thừa / vừa), dưới là 2 ô bên phải / trái */
.pm-tong { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pm-tong > .o { border-radius: 12px; padding: 8px 9px 9px; background: #fff; border: 1px solid var(--line); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.pm-tong > .o:hover { border-color: #9cc9c4; }
.pm-tong > .o.on { border-color: var(--c4); box-shadow: 0 0 0 1px var(--c4), 0 4px 14px rgba(8,145,178,.1); }
.pm-tong .dau { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 7px; }
.pm-tong small { font-size: 12.5px; font-weight: 800; color: var(--ink); }
.pm-tong .so { font-size: 13px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: #f1f5f9; color: #94a3b8; white-space: nowrap; }
.pm-tong .so.am { background: #fee2e2; color: #b91c1c; } .pm-tong .so.duong { background: #dcfce7; color: #15803d; } .pm-tong .so.vua { background: #e0f2fe; color: #0369a1; }
.pm-tong .ben { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pm-tong .ben > div { border-radius: 8px; padding: 4px 8px; background: #f8fafc; border-left: 3px solid #cbd5e1; min-width: 0; }
.pm-tong .ben small { display: block; font-size: 11px; font-weight: 700; color: var(--muted); }
.pm-tong .ben b { display: block; font-size: 12.5px; font-weight: 800; color: #334155; white-space: nowrap; }
.pm-tong .ben .am { border-left-color: #f87171; } .pm-tong .ben .am b { color: #b91c1c; }
.pm-tong .ben .duong { border-left-color: #4ade80; } .pm-tong .ben .duong b { color: #15803d; }
.pm-tong .ben .vua { border-left-color: #7dd3fc; } .pm-tong .ben .vua b { color: #0369a1; }
.pm .am { color: #dc2626; } .pm .duong { color: #16a34a; }
.pm-nho { font-size: 12px; color: var(--muted); font-weight: 600; }

/* phần 1: công cụ trên ảnh (lõi js/mau/ptm_core.js đổi chữ nút khi đang vẽ / xóa / đo) */
.pm .pm-tb { height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 0 10px; font-weight: 700; font-size: 12.5px; color: #38505b; white-space: nowrap; }
.pm .pm-tb:hover { border-color: #9cc9c4; background: #f0fdfa; }
.pm .pm-tb.bat { background: var(--c4s); border-color: var(--c4); color: var(--c4); }
.pm-goc { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: #38505b; }
.pm-goc .pm-tb { padding: 0 8px; }
.pm-thuoc { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.pm-thuoc input { width: 58px; height: 28px; border: 1px solid #cbd5e1; border-radius: 6px; text-align: center; font: inherit; font-weight: 700; }
.pm-seg button.chon { background: #fff; color: var(--c4); box-shadow: 0 1px 4px rgba(20,60,70,.12), inset 0 0 0 1.5px var(--c4); }
.pm-seg.nho button { padding: 3px 9px; font-size: 12px; }
.ptm-khung { display: flex; align-items: center; background: #1d2a2e; }
.ptm-khung canvas { display: block; width: 100%; touch-action: none; }
.ptm-khung canvas.keo-diem { cursor: grabbing; }
.ptm-khung canvas.dang-do, .ptm-khung canvas.dang-ve { cursor: crosshair; }
.ptm-khung canvas.dang-xoa { cursor: pointer; }
.ptm-trong, .ptm-dang { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; color: #cfd9da; font-weight: 700; font-size: 13px; }
.ptm-dang { background: rgba(29,42,46,.7); color: #fff; }
/* thông báo của lõi (đổi tên / xóa răng): nổi trên mép trên ảnh, không đẩy ảnh; bấm = ẩn */
.ptm-bao { position: absolute; left: 10px; right: 10px; top: 8px; z-index: 3; padding: 6px 10px; background: rgba(234,247,239,.96); border: 1px solid #b9e2c8; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: #14532d; box-shadow: 0 4px 14px rgba(0,0,0,.25); cursor: pointer; }
.ptm-bao[hidden] { display: none; }
.pm-lfoot { display: flex; align-items: center; gap: 4px 10px; padding: 6px 10px; border-top: 1px solid var(--line); flex-wrap: wrap; font-size: 11.5px; font-weight: 600; color: #38505b; }
.pm-lfoot label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.pm-lfoot input[type=checkbox] { accent-color: var(--c4); width: 13px; height: 13px; margin: 0; }
/* 2 hàng cố định: lớp hiển thị | Mô phỏng (+ thanh tiến trình) … Nhổ răng — bật Mô phỏng không sinh thêm dòng */
.pm-lfoot .pm-xuong { flex-basis: 100%; height: 0; }
.pm-lfoot .mp { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.pm .pm-lfoot .pm-nhoNut { margin-left: auto; }
.pm-lfoot .mp b { color: var(--c4); }
.pm-lfoot #ptm_mpO { display: inline-flex; align-items: center; gap: 4px; }
.pm-lfoot #ptm_mpO[hidden] { display: none; }
.pm-lfoot input[type=range] { width: 70px; }
.pm .pm-lfoot .pm-nb { height: 22px; padding: 0 7px; font-size: 11px; }
.pm .pm-lfoot .pm-nhoNut { height: 24px; padding: 0 9px; font-size: 11.5px; }
/* công cụ trên ảnh phần 1: chữ nhỏ để ô thước (số mm + Ẩn) không đẩy xuống dòng */
.pm .pm-cong { gap: 5px; padding: 6px 8px; }
.pm .pm-cong .pm-tb { height: 26px; padding: 0 8px; font-size: 11.5px; border-radius: 8px; }
.pm .pm-cong .pm-goc { font-size: 11.5px; gap: 3px; }
.pm .pm-cong .pm-thuoc { font-size: 11.5px; gap: 3px; }
.pm .pm-cong .pm-thuoc input { width: 46px; height: 24px; font-size: 11.5px; }
.pm .pm-cong .pm-tick { font-size: 11.5px; }
.pm input[type=range] { accent-color: var(--c4); }

/* ================= phần 1: ảnh | cột công cụ | nội dung (2026-11-05) =================
   Ảnh giữ bề rộng cũ (9/26 khi 2 cột); nút nào hiện / ẩn theo trạng thái thì giữ chỗ để cột không nhảy. */
#pmS1 { position: relative; grid-template-columns: calc((100% - 8px) * 9 / 26) 186px minmax(0, 1fr); }
.pm-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
#mauStepContainer:not(.p2) #ptmBan > .pm-cong { display: none; }      /* phần 1: hàng nút trên ảnh trống */
.pm-cong .pm-nhomCong { display: contents; }

/* dòng trạng thái trên ảnh: luôn 1 dòng */
.pm-trangThai { flex: 0 0 auto; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: #38505b; transition: background .2s, color .2s; min-width: 0; }
.pm-trangThai .ic { flex: 0 0 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: #eef3f4; color: var(--c4); }
.pm-trangThai .ic svg { width: 15px; height: 15px; }
.pm-trangThai .chu { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-trangThai .ham { flex: 0 0 auto; font-size: 11.5px; font-weight: 800; color: var(--c4); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.pm .pm-trangThai kbd, .pm-hd kbd { font: 700 11px/1 inherit; background: #fff; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: #334155; }
.pm .do { color: #ef4444; } .pm .vang { color: #ca8a04; }
.pm-trangThai.ve { background: var(--c4s); color: #0e5f74; } .pm-trangThai.ve .ic { background: var(--c4); color: #fff; }
.pm-trangThai.xoa { background: #fee2e2; color: #991b1b; } .pm-trangThai.xoa .ic { background: #dc2626; color: #fff; }
.pm-trangThai.thuoc { background: #fef3c7; color: #92400e; } .pm-trangThai.thuoc .ic { background: #d97706; color: #fff; }
#mauStepContainer.p2 .pm-trangThai .chu { opacity: .6; }

/* cột công cụ: tự cuộn dọc nếu thấp (nút luôn tới được) */
.pm-cot { min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; padding: 9px 9px 10px; display: flex; flex-direction: column; gap: 10px; }
.pm-cot h5 { margin: 0 0 6px 2px; font-size: 10.5px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.pm-cotHam { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.pm .pm-cotHam button { height: 50px; border: 1.5px solid var(--line); background: #fff; border-radius: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-weight: 800; font-size: 11.5px; color: var(--muted); padding: 0; }
.pm-cotHam button svg { width: 28px; height: 20px; }
.pm .pm-cotHam button.chon { border-color: var(--c4); background: var(--c4s); color: var(--c4); box-shadow: 0 0 0 1px var(--c4); }
.pm-choCong .pm-nhomCong { display: flex; flex-direction: column; gap: 5px; }

/* nút công cụ có icon (cả hàng nút phần 2) */
.pm .pm-cc { display: inline-flex; align-items: center; gap: 6px; }
.pm-cc .ic { display: grid; place-items: center; color: var(--c4); }
.pm-cc .ic svg { width: 15px; height: 15px; }
.pm-cc .hoi { display: none; }
#ptm_xoaRang .ic { color: #dc2626; } #ptm_nutThuoc .ic { color: #d97706; } #ptm_hoanTac .ic { color: #475569; }
.pm .pm-cc.bat .ic { color: inherit; }
.pm #pmCot .pm-cc { position: relative; width: 100%; height: 38px; padding: 0 26px 0 6px; gap: 7px; border-width: 1.5px; border-radius: 10px; font-size: 12px; color: #2b4350; text-align: left; }
.pm #pmCot .pm-cc .chu { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#pmCot .pm-cc .ic { flex: 0 0 26px; height: 26px; border-radius: 8px; background: #eef6f7; }
#pmCot .pm-cc .ic svg { width: 16px; height: 16px; }
#pmCot #ptm_xoaRang .ic { background: #fef2f2; } #pmCot #ptm_nutThuoc .ic { background: #fffbeb; } #pmCot #ptm_hoanTac .ic { background: #f1f5f9; }
#pmCot .pm-cc .hoi { display: grid; place-items: center; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 11px; font-weight: 800; }
#pmCot .pm-cc .hoi:hover { border-color: var(--c4); color: var(--c4); }
.pm #pmCot .pm-cc.bat { border-color: var(--c4); background: var(--c4s); color: #0e5f74; }
.pm #pmCot .pm-cc.bat .ic { background: var(--c4); color: #fff; }
.pm #pmCot #ptm_xoaRang.bat { border-color: #dc2626; background: #fee2e2; color: #991b1b; }
.pm #pmCot #ptm_xoaRang.bat .ic { background: #dc2626; }
.pm #pmCot #ptm_nutThuoc.bat { border-color: #d97706; background: #fef3c7; color: #92400e; }
.pm #pmCot #ptm_nutThuoc.bat .ic { background: #d97706; }
/* lõi ẩn nút khi chưa dùng được (Xóa răng chưa có ảnh, Trả về khi chưa chỉnh tay): ở cột giữ chỗ, mờ */
#mauStepContainer.pm #pmCot .pm-cc[hidden] { display: inline-flex !important; opacity: .42; pointer-events: none; }
/* ô thước ở cột: từng phần 1 dòng riêng, rộng hết ô */
#pmCot .pm-thuoc { display: flex; flex-direction: column; align-items: stretch; gap: 5px; padding: 7px; border: 1px dashed #f0c27a; border-radius: 9px; background: #fffbeb; font-size: 11.5px; color: #92400e; }
#pmCot .pm-thuoc[hidden] { display: none; }
.pm-thuocT { display: none; }
#pmCot .pm-thuocT { display: block; font-weight: 600; font-size: 11px; line-height: 1.3; }
#pmCot .pm-thuocS { display: flex; align-items: center; gap: 5px; font-weight: 700; }
#pmCot .pm-thuoc input { width: 70px; height: 28px; border: 1.5px solid #d97706; }
.pm #pmCot .pm-thuoc .pm-tb, .pm #pmCot .pm-thangTD { width: 100%; height: 28px; padding: 0 8px; font-size: 11.5px; border-color: #f0c27a; color: #92400e; overflow: hidden; text-overflow: ellipsis; }
#pmCot .pm-thangTD[hidden] { display: none; }

/* công tắc hiển thị */
.pm-hienDs { display: flex; flex-direction: column; gap: 2px; }
.pm-batTat { position: relative; display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 4px 6px; border-radius: 9px; cursor: pointer; font-size: 12px; font-weight: 700; color: #2b4350; line-height: 1.25; user-select: none; }
.pm-batTat:hover { background: #f3f8f8; }
.pm-batTat input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.pm-batTat .sw { position: relative; flex: 0 0 28px; height: 16px; border-radius: 999px; background: #cfdcde; transition: background .15s; }
.pm-batTat .sw::after { content: ''; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.pm-batTat input:checked + .sw { background: var(--c4); }
.pm-batTat input:checked + .sw::after { transform: translateX(12px); }
.pm-batTat input:focus-visible + .sw { outline: 2px solid var(--c4); outline-offset: 2px; }
.pm-batTat .ten { min-width: 0; }
.pm-batTat .ten i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 1px; }
.pm-batTat small { color: var(--muted); font-weight: 700; }

/* xoay ảnh ở cột: hàng 1 ↶ 0° ↷, hàng 2 Về 0° | Vừa khung (giữ chỗ khi ẩn) */
.pm-cot .pm-xoayCho { margin: 0; display: block; }
.pm-cot .pm-goc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; align-items: center; }
.pm-cot .pm-goc .pm-xoayTen { display: none; }
.pm-cot .pm-goc b { text-align: center; font-size: 13px; }
.pm .pm-cot .pm-goc .pm-tb { height: 30px; padding: 0; font-size: 15px; }
.pm .pm-cot .pm-goc #ptm_xoay0, .pm .pm-cot .pm-goc #ptm_vuaKhung { font-size: 11.5px; grid-row: 2; }
.pm-cot .pm-goc #ptm_xoay0 { grid-column: 1 / 2; }
.pm-cot .pm-goc #ptm_vuaKhung { grid-column: 2 / 4; }
#mauStepContainer.pm .pm-cot .pm-goc [hidden] { display: block !important; visibility: hidden; }

/* thẻ hướng dẫn: nổi cạnh cột công cụ, mũi trỏ vào nút */
.pm-hd { position: absolute; z-index: 60; width: 340px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 14px 40px rgba(15,40,50,.22); padding: 12px 14px; color: var(--ink); animation: pmHdVao .18s ease-out; }
.pm-hd[hidden] { display: none; }
@keyframes pmHdVao { from { opacity: 0; transform: translateX(-6px); } }
.pm-hd::before { content: ''; position: absolute; left: -7px; top: var(--mui, 18px); width: 12px; height: 12px; background: #fff; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg); }
.pm-hdT { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14.5px; }
.pm-hdT .ic { flex: 0 0 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--c4); color: #fff; }
.pm-hdT .ic svg { width: 17px; height: 17px; }
.pm .pm-hdT .x { margin-left: auto; width: 28px; height: 28px; border: 0; background: #f1f5f6; border-radius: 50%; color: var(--muted); font-weight: 800; padding: 0; }
.pm-hd[data-loai="xoa"] .pm-hdT .ic { background: #dc2626; }
.pm-hd[data-loai="thuoc"] .pm-hdT .ic { background: #d97706; }
.pm-hd[data-loai="tra"] .pm-hdT .ic { background: #475569; }
.pm-hdDung { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.pm-hdDemo { border-radius: 10px; overflow: hidden; background: #1d2a2e; }
.pm-hdDemo svg { display: block; width: 100%; height: auto; }
.pm-hd ol { margin: 10px 0 0; padding: 0; list-style: none; counter-reset: b; display: flex; flex-direction: column; gap: 6px; }
.pm-hd ol li { counter-increment: b; display: flex; gap: 8px; font-size: 12.5px; line-height: 1.45; }
.pm-hd ol li::before { content: counter(b); flex: 0 0 20px; height: 20px; border-radius: 50%; background: var(--c4s); color: var(--c4); font-weight: 800; font-size: 11px; display: grid; place-items: center; }
.pm-hdChuY { margin-top: 9px; padding: 7px 9px; border-radius: 9px; background: #f8fafc; border: 1px solid var(--line); font-size: 12px; line-height: 1.5; color: #38505b; }
.pm-hdCuoi { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pm-hdCuoi label { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 600; cursor: pointer; }
.pm-hdCuoi input { accent-color: var(--c4); margin: 0; }
.pm .pm-hdCuoi .ok { margin-left: auto; height: 34px; padding: 0 16px; border: 0; border-radius: 9px; background: var(--c4); color: #fff; font-weight: 800; }
.pm .pm-hd[data-loai="tra"] .pm-hdCuoi .ok { background: #475569; }
.pm .pm-hdCuoi .thoi { height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-weight: 700; color: #38505b; }

/* hàng dưới ảnh: 2 dòng cố định — Mô phỏng (+ thanh tiến trình) | Nhổ răng… + răng đã chọn (cắt "…");
   bật Mô phỏng / chọn răng nhổ không sinh thêm dòng, không đè nút */
#pmS1 .pm-lfoot { flex-wrap: wrap; min-width: 0; }
#pmS1 .pm-lfoot .mp { min-width: 0; flex: 1 1 100%; height: 24px; }
#pmS1 .pm-lfoot #ptm_mpO { min-width: 0; flex: 1 1 auto; }
#pmS1 .pm-lfoot input[type=range] { width: auto; flex: 1 1 70px; min-width: 50px; max-width: 160px; }
#pmS1 .pm-lfoot .pm-nho { min-width: 0; flex: 1 1 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm #pmS1 .pm-lfoot .pm-nhoNut { flex: 0 0 auto; margin-left: 0; }

/* đầu thẻ ở cột nội dung hẹp: nút phụ xuống dòng gọn, không đẩy ô số */
#pmS1 .pm-right .cc-h.sau { row-gap: 4px; }
#pmS1 .pm-right .cc-h .pm-nutThuoc, #pmS1 .pm-right .cc-h .pm-nb { white-space: nowrap; }
#pmS1 .pm-right .pm-cap { flex-wrap: wrap; }

/* phần 1: cột phải */
.ptm-canh { border: 1px solid #fde68a; background: #fffbeb; border-radius: 10px; padding: 6px 10px; font-size: 12px; color: #92400e; }
.ptm-canh ul { margin: 0; padding-left: 16px; }
.pm-blk { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.pm-blk h3 { margin: 0 0 7px; font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.pm-blk h3 .r { margin-left: auto; }
.pm-thanh { display: block; margin: 2px 0 4px; font-weight: 700; font-size: 12.5px; }
.pm-thanh b { float: right; color: var(--c4); }
.pm-thanh input { width: 100%; margin-top: 4px; }
.pm-hang { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pm .pm-nb { height: 27px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0 10px; font-weight: 700; font-size: 12px; color: #38505b; }
.pm .pm-nb:hover { border-color: #9cc9c4; }
.pm .pm-nb.on { background: var(--c4); border-color: var(--c4); color: #fff; }
#ptm_dsNho { color: #dc2626; font-weight: 700; }
table.pm-kq { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.pm-kq td { padding: 4px 2px; border-bottom: 1px dashed #e5eced; }
table.pm-kq th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 700; padding: 2px; }

/* thẻ nhập giống Trang 5 (slide_editor.js + page5.css) */
.pm .criterion-card { background: #fff; border: 1px solid #e6eeef; border-radius: 9px; padding: 6px 8px; margin: 0; display: flex; flex-direction: column; }
.pm .criterion-card:hover { border-color: #a7e3cb; background: #fbfefd; }
.pm .cc-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.pm .cc-h label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.pm .cc-h input { width: 15px; height: 15px; accent-color: #16a34a; margin: 0; }
.pm .cc-h span { font-weight: 700; color: #0f172a; font-size: .82rem; }
.pm .opt-chips-wrap { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.pm .opt-chip { padding: 2px 8px; font-size: .74rem; border-radius: 999px; border: 1px solid #cbd5e1; background: #fff; color: #334155; font-weight: 500; }
.pm .opt-chip:hover { border-color: #059669; color: #047857; }
.pm .opt-chip.selected { background: #059669; border-color: #059669; color: #fff; font-weight: 700; box-shadow: 0 1px 3px rgba(5,150,105,.25); }
.pm .cc-ta { position: relative; margin-top: 2px; display: flex; }
.pm .cc-ta textarea { padding: 4px 6px; font: inherit; font-size: .75rem; min-height: 27px; line-height: 1.4; border-radius: 4px; border: 1px solid #cbd5e1; width: 100%; resize: vertical; }
.pm-cap { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pm-cap label { display: flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: #38505b; flex-wrap: wrap; }
.pm-cap input { width: 64px; height: 26px; padding: 2px 6px; border: 1px solid #cbd5e1; border-radius: 4px; font: inherit; font-weight: 700; text-align: center; color: var(--ink); }
.pm-cap input.tay { background: #fffbeb; border-color: #f59e0b; }
.pm input:focus, .pm textarea:focus { outline: none; border-color: #059669 !important; box-shadow: 0 0 0 3px rgba(5,150,105,.14); }
/* phần 2: thẻ slide 7 (cặp phải / trái, sơ đồ cung cắn chéo / hở); cam = app tự điền chưa chắc, bấm để xác nhận */
.pm-dsk { display: flex; flex-direction: column; gap: 7px; }
.pm .p5-pair-card { background: #fff; border: 1px solid #e6eeef; border-radius: 9px; padding: 6px 8px 4px; }
.pm .p5-pair-title { font-weight: 700; color: #0f172a; font-size: .82rem; margin: 0 0 4px; }
.pm .p5-pair { display: grid; grid-template-columns: 1fr 1fr; }
.pm .p5-pair > .criterion-card.p5-side { border: none; box-shadow: none; margin: 0; border-radius: 6px; padding: 3px 8px 4px 2px; min-width: 0; }
.pm .p5-pair > .criterion-card.p5-side + .p5-side { padding: 3px 2px 4px 10px; border-left: 1.5px solid #cfdcdf; border-radius: 0 6px 6px 0; }
.pm .p5-pair > .p5-side .cc-h span { font-size: .78rem; color: #38505b; }
.pm .p5-arch { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) 14px repeat(3, minmax(0, 1fr)) 8px repeat(3, minmax(0, 1fr)) 14px repeat(4, minmax(0, 1fr)); grid-template-rows: auto 27px 2px 27px; column-gap: 2px; row-gap: 3px; padding: 5px 6px 6px; margin-bottom: 4px; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 6px; }
.pm .p5-arch-cap { grid-row: 1; text-align: center; font-size: .68rem; font-weight: 700; color: #64748b; }
.pm .p5-arch-cap.ant { color: #0369a1; }
.pm .p5-arch-h { grid-row: 3; grid-column: 1 / -1; background: #0284c7; }
.pm .p5-arch-v { grid-row: 2 / 5; grid-column: 9; justify-self: center; width: 2px; background: #0284c7; }
.pm .btn-tooth-chip { width: 100%; height: 27px; padding: 0; font-size: .72rem; border-radius: 3px; border: 1px solid #cbd5e1; background: #fff; color: #0369a1; font-weight: 600; }
.pm .btn-tooth-chip.selected { background: #059669; border-color: #059669; color: #fff; }
.pm .opt-chip.selected.nghi, .pm .btn-tooth-chip.selected.nghi { background: #f59e0b; border-color: #f59e0b; box-shadow: 0 0 0 2px #fde68a; }
.pm .pm-mm.nghi { color: #b45309; border-color: #f59e0b; box-shadow: 0 0 0 2px #fde68a; }
/* phần 3: đường giữa (slide 8) + Bolton (slide 9) */
.pm-nhan { font-size: 13px; font-weight: 800; color: #38505b; line-height: 30px; }
.pm .cc-num { display: flex; align-items: center; gap: 6px; margin-top: 1px; font-size: .75rem; color: #475569; }
.pm .cc-num input { flex: 0 0 70px; height: 25px; padding: 2px 6px; font: inherit; font-weight: 700; text-align: center; border-radius: 4px; border: 1px solid #cbd5e1; }
.pm .cc-num span { font-weight: 600; color: #64748b; }
.pm .cc-num input.tay, .pm-bgrid input.tay { background: #fffbeb; border-color: #f59e0b; }
.pm-btong { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; margin: 2px 0 6px; }
.pm-btong + .pm-bgrid + .pm-btong { margin-top: 10px; }
.pm-bgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.pm-bgrid div { text-align: center; min-width: 0; }
.pm-bgrid small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
.pm-bgrid input { width: 100%; height: 27px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 5px; text-align: center; font: inherit; font-weight: 700; color: var(--ink); -moz-appearance: textfield; }
.pm-bgrid input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pm-bgrid input.nghi { border-color: #f59e0b; box-shadow: 0 0 0 2px #fde68a; }
.pm-bkq { border-radius: 10px; background: #f0fdf4; border: 1px solid #86efac; padding: 8px 10px; font-size: 12.5px; color: #14532d; }
.pm-bkq.xau { background: #fef2f2; border-color: #fca5a5; color: #7f1d1d; }
.pm-bkq.trong { background: #f8fafc; border-color: var(--line); }
.pm-bty { display: flex; align-items: baseline; gap: 8px; }
.pm-bty span { font-size: 22px; font-weight: 800; color: var(--ink); }
.pm-bthuoc { position: relative; height: 26px; margin: 8px 0 2px; }
.pm-bthuoc .nen { position: absolute; left: 0; right: 0; top: 10px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #fecaca 0 34%, #bbf7d0 34% 66%, #fecaca 66%); }
.pm-bthuoc .kim { position: absolute; top: 3px; width: 3px; height: 20px; background: #0f172a; border-radius: 2px; transform: translateX(-50%); }
.pm-bthuoc span { position: absolute; top: -2px; font-size: 10px; color: var(--muted); transform: translateX(-50%); font-weight: 700; }
.pm-nx { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: #dcfce7; color: #15803d; white-space: nowrap; }
.pm-nx:empty { display: none; }
.pm-nx.xau { background: #fee2e2; color: #b91c1c; }

/* hộp thoại nhổ răng / đổi tên răng (lõi app gốc) */
.ptm-dlg[open] { position: fixed; inset: 0; margin: auto; height: fit-content; max-height: 90vh; overflow: auto; z-index: 1000; }
.ptm-dlg { border: 0; border-radius: 14px; padding: 16px 18px; box-shadow: 0 30px 80px rgba(0,0,0,.35); font: 13px/1.4 'Be Vietnam Pro', system-ui, sans-serif; color: #142b38; max-width: 560px; }
.ptm-dlg::backdrop { background: rgba(15,23,42,.45); }
.ptm-dlg h2 { margin: 0 0 10px; font-size: 16px; }
.ptm-dlg .dong { float: right; border: 0; background: #f1f5f9; border-radius: 8px; width: 28px; height: 28px; cursor: pointer; }
.ptm-dlg .bang-chon { margin: 12px 0; }
.ptm-dlg .bang-chon .ben-ten { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 8px; color: #607580; font-size: 12px; }
.ptm-dlg .bang-chon .ben-ten span:first-child { grid-column: 2; text-align: right; padding-right: 6px; }
.ptm-dlg .bang-chon .hang { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 8px; align-items: center; margin: 6px 0; }
.ptm-dlg .bang-chon .nhan { font-weight: 700; font-size: 12px; }
.ptm-dlg .bang-chon .nua { display: flex; gap: 4px; }
.ptm-dlg .bang-chon .nua:first-of-type { justify-content: flex-end; border-right: 2px solid #0891b2; padding-right: 6px; }
.ptm-dlg .bang-chon button { width: 38px; height: 34px; padding: 0; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; cursor: pointer; font: inherit; font-weight: 700; }
.ptm-dlg .bang-chon button:hover:not(:disabled) { border-color: #0891b2; color: #0891b2; }
.ptm-dlg .bang-chon button.hien { background: #0891b2; border-color: #0891b2; color: #fff; }
.ptm-dlg .bang-chon button.dung { text-decoration: underline; text-decoration-color: #c4572a; text-decoration-thickness: 2px; }
.ptm-dlg .bang-chon button:disabled { opacity: .3; cursor: not-allowed; }
.ptm-dlg .bang-chon button.chon { background: #dc2626; border-color: #dc2626; color: #fff; }
.ptm-dlg .pm-nb { height: 30px; border: 1px solid #dfe8e9; background: #fff; border-radius: 8px; padding: 0 12px; font-weight: 700; cursor: pointer; }
.ptm-dlg .pm-nb.on { background: #0891b2; border-color: #0891b2; color: #fff; }
.ptm-dlg .pm-seg { display: inline-flex; background: #f3f7f7; border: 1px solid #dfe8e9; border-radius: 10px; padding: 2px; gap: 2px; }
.ptm-dlg .pm-seg button { border: 0; background: transparent; border-radius: 8px; padding: 5px 11px; font-weight: 700; cursor: pointer; }
.ptm-dlg .pm-seg button.chon { background: #fff; color: #0891b2; box-shadow: inset 0 0 0 1.5px #0891b2; }

@media (max-width: 1100px) {
  /* màn hẹp: ảnh trên, nội dung dưới, cuộn cả trang như thường */
  .pm-sec, #pmS1, #pmS2, #pmS3 { grid-template-columns: minmax(0, 1fr); height: auto; }
  html.pm-cuonKhuc { scroll-snap-type: none; }
  html.pm-cuonKhuc #mauStepContainer.pm { padding-bottom: 12px; }
  .pm-left { position: relative; top: 0; height: 62vh; }
  #pmS1 .pm-left { height: 78vh; }
  #pmS2 .pm-left, #pmS3 .pm-left { height: auto; }
  .pm-g3 { grid-template-rows: 40vh auto; }
  .pm-right { min-height: 0; height: auto; overflow: visible; }
  .pm-phongk { width: 94vw; height: 80vh; }
  .pm-phong[data-menu] .pm-phongk { flex-direction: column; width: 94vw; height: 88vh; }
  .pm-phong[data-menu] .pm-phongMenu { flex: 0 0 auto; max-height: 42%; border-left: 0; border-top: 1px solid var(--line); }
  /* phần 1: ảnh rộng như cũ; cột công cụ thành các nhóm xếp ngang ngay dưới ảnh; thẻ hướng dẫn = tấm dưới đáy */
  #pmS1 { grid-template-columns: minmax(0, 1fr); }
  #pmS1 .pm-cot { height: auto; overflow: visible; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 14px; align-items: start; }
  .pm-hd { position: fixed; left: 12px !important; right: 12px; top: auto !important; bottom: 12px; width: auto; max-width: 560px; margin: 0 auto; max-height: 70vh; overflow-y: auto; }
  .pm-hd::before { display: none; }
}
@media (max-width: 599px) {
  /* thanh trên điện thoại cao, xuống dòng: thanh 3 phần không dính, chữ ngắn lại */
  .pm-phan { position: relative; top: 0; }
  .pm-phan > div { height: auto; min-height: 42px; }
  .pm-phan button { font-size: 11.5px; gap: 5px; white-space: normal; line-height: 1.15; text-align: left; padding: 3px 4px; }
  .pm-phan button b { display: none; }
  .pm-left { height: 52vh; }
  #pmS1 .pm-left { height: 72vh; }
  .pm-luoi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pm-g3 { grid-template-columns: minmax(0, 1fr); grid-template-rows: 46vh 30vh auto; }
  /* điện thoại: dòng trạng thái chữ nhỏ, bỏ nhãn hàm (đã có ở cột công cụ) */
  #pmS1 .pm-cot { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pm-trangThai { font-size: 11.5px; }
  .pm-trangThai .ham { display: none; }
}
