/* soan.css — màn soạn toàn trang (chuyên gia C). Tiền tố .soan-  ; chỉ dùng biến của app.css, có giá trị lùi. */
.soan, .soan-lop {
  --s-nen: var(--nen, #f6f4ee);
  --s-nen2: var(--nen2, #fffdf8);
  --s-chu: var(--chu, #23262b);
  --s-phu: var(--chu-phu, #565d69);
  --s-vien: var(--vien, #ddd7c8);
  --s-chinh: var(--chinh, #0f6b5c);
  --s-chinh-chu: var(--chinh-chu, #fff);
  --s-nhan: var(--nhan, #d9822b);
  --s-loi: var(--loi, #b3261e);
  --s-ok: var(--ok, #1e7a3c);
  --s-canh: var(--canh-bao, #a8650f);
  --s-goc: var(--bo-goc, 12px);
  --s-bong: var(--bong, 0 6px 24px rgba(30,30,20,.18));
  --s-san: #101418;
  --s-nen-chon: color-mix(in srgb, var(--s-chinh) 14%, var(--s-nen2));
  font-family: "Be Vietnam Pro", system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--s-chu);
}
.soan {
  position: fixed; inset: 0; z-index: 900; background: var(--s-nen);
  display: flex; flex-direction: column; min-height: 0; font-size: 15px; line-height: 1.45;
}
.soan *, .soan *::before, .soan *::after { box-sizing: border-box; }
.soan button, .soan input, .soan select, .soan textarea { font: inherit; color: inherit; }
.soan button { cursor: pointer; }
.soan :focus-visible, .soan-lop :focus-visible { outline: 3px solid var(--s-nhan); outline-offset: 2px; }
.soan [hidden] { display: none !important; }

/* ===== nút ===== */
.soan-nut {
  min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--s-vien);
  background: var(--s-nen2); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap; transition: background 120ms, border-color 120ms;
}
.soan-nut:hover:not(:disabled) { background: var(--s-nen-chon); border-color: var(--s-chinh); }
.soan-nut:disabled { opacity: .45; cursor: not-allowed; }
.soan-nut.chinh { background: var(--s-chinh); color: var(--s-chinh-chu); border-color: var(--s-chinh); font-weight: 600; }
.soan-nut.chinh:hover:not(:disabled) { filter: brightness(1.1); background: var(--s-chinh); }
.soan-nut.nguy { color: var(--s-loi); }
.soan-nut.tro { border-color: transparent; background: transparent; }
.soan-nut.nho { min-height: 36px; padding: 0 10px; font-size: 14px; }
.soan-nut[aria-pressed="true"], .soan-nut[aria-expanded="true"] { background: var(--s-nen-chon); border-color: var(--s-chinh); }

/* ===== đầu trang ===== */
.soan-dau {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--s-nen2); border-bottom: 1px solid var(--s-vien);
}
.soan-ten {
  flex: 1 1 180px; min-width: 120px; min-height: 44px; padding: 0 10px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; font-weight: 700; font-size: 17px;
  text-overflow: ellipsis;
}
.soan-ten:hover { border-color: var(--s-vien); }
.soan-ten:focus { border-color: var(--s-chinh); background: var(--s-nen); }
.soan-luu { font-size: 13px; color: var(--s-phu); min-width: 96px; text-align: center; }
.soan-luu.loi { color: var(--s-loi); font-weight: 600; }
.soan-soat-so { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; font-size: 12px; font-weight: 700; color: #fff; text-align: center; }
.soan-soat-so.do { background: var(--s-loi); }
.soan-soat-so.vang { background: #b97a00; }
.soan-soat-so.ok { background: var(--s-ok); }

/* ===== thanh công cụ ===== */
.soan-cc {
  display: flex; gap: 6px; padding: 6px 12px; overflow-x: auto; background: var(--s-nen);
  border-bottom: 1px solid var(--s-vien); scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.soan-cc .soan-nut { flex: 0 0 auto; flex-direction: column; gap: 0; padding: 2px 10px; min-height: 52px; font-size: 12.5px; line-height: 1.2; }
.soan-cc .bieu-tuong { font-size: 19px; line-height: 1.1; }
.soan-cc .cach { flex: 0 0 1px; background: var(--s-vien); margin: 6px 4px; }

/* ===== khung ba cột ===== */
.soan-than {
  flex: 1 1 auto; min-height: 0; display: grid;
  grid-template-columns: 208px minmax(0, 1fr) 340px; grid-template-areas: "trai giua phai"; position: relative;
}
.soan-trai { grid-area: trai; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--s-vien); background: var(--s-nen2); }
.soan-giua { grid-area: giua; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--s-san); }
.soan-phai { grid-area: phai; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--s-vien); background: var(--s-nen2); }

/* ===== cột trang ===== */
.soan-ds { list-style: none; margin: 0; padding: 8px; overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; }
.soan-th { position: relative; display: grid; grid-template-columns: 22px 1fr; gap: 4px; align-items: start; padding: 4px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; }
.soan-th:hover { background: var(--s-nen); }
.soan-th.chon { border-color: var(--s-chinh); background: var(--s-nen-chon); }
.soan-th.cung { border-color: color-mix(in srgb, var(--s-chinh) 55%, transparent); }
.soan-th .so { font-size: 12px; color: var(--s-phu); text-align: right; padding-top: 2px; font-weight: 600; }
.soan-th .anh { position: relative; width: 100%; aspect-ratio: 16/9; overflow: hidden; border-radius: 6px; background: #fff; border: 1px solid var(--s-vien); pointer-events: none; }
.soan-th .ve { position: absolute; inset: 0; }
.soan-th .nhan { grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: 4px; font-size: 12px; color: var(--s-phu); min-height: 24px; }
.soan-th .nhan span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soan-th .ba-cham { min-height: 30px; min-width: 30px; padding: 0; border-radius: 8px; border: 1px solid transparent; background: transparent; }
.soan-th .ba-cham:hover { border-color: var(--s-vien); background: var(--s-nen2); }
.soan-th.an .anh { opacity: .45; }
.soan-th.an .anh::after { content: "Ẩn khi chiếu"; position: absolute; inset: auto 0 0 0; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; text-align: center; padding: 2px; }
.soan-th.keo-truoc { box-shadow: 0 -3px 0 0 var(--s-nhan); }
.soan-th.keo-sau { box-shadow: 0 3px 0 0 var(--s-nhan); }
.soan-th.dang-keo { opacity: .4; }
.soan-them-trang { margin: 8px; }

/* ===== sân khấu ===== */
.soan-san { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 14px; overflow: hidden; }
.soan-hop { position: relative; background: #fff; box-shadow: 0 8px 40px rgba(0,0,0,.5); border-radius: 4px; overflow: hidden; flex: 0 0 auto; }
.soan-ve { position: absolute; inset: 0; overflow: hidden; }
.soan-phu { position: absolute; inset: 0; z-index: 2; }
.soan-ve-loi { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: #333; background: #f4f4f4; }
.soan-vung {
  position: absolute; border: 2px dashed transparent; border-radius: 4px; background: transparent; padding: 0; cursor: text;
  transition: border-color 120ms, background 120ms;
}
.soan-vung:hover { border-color: rgba(255,180,60,.9); background: rgba(255,180,60,.08); }
.soan-vung.chon { border: 2px solid #ffb43c; background: rgba(255,180,60,.12); }
.soan-vung.anh { cursor: pointer; }
.soan-vung .nhan-vung { position: absolute; left: -2px; top: -22px; padding: 1px 6px; font-size: 11px; background: #ffb43c; color: #2a1a00; border-radius: 4px 4px 0 0; white-space: nowrap; display: none; pointer-events: none; }
.soan-vung.chon .nhan-vung { display: block; }
.soan-sua {
  position: absolute; z-index: 5; margin: 0; padding: 4px 8px; border: 2px solid #ffb43c; border-radius: 4px; outline: none; overflow: auto;
  background: #fffdf5; color: #1d1d1d; white-space: pre-wrap; word-break: break-word; box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.soan-keo-tha { position: absolute; inset: 0; z-index: 4; display: none; align-items: center; justify-content: center; background: rgba(15,107,92,.78); color: #fff; font-size: 22px; font-weight: 700; border: 4px dashed #fff; }
.soan-san.dang-tha .soan-keo-tha { display: flex; }
.soan-chan { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 12px; background: #1b2026; color: #e8e6df; font-size: 13px; flex-wrap: wrap; }
.soan-chan .soan-nut { background: #262d35; color: #e8e6df; border-color: #3a434d; min-height: 44px; }
.soan-chan .soan-nut:hover:not(:disabled) { background: #323b45; }
.soan-meo { color: #aeb4bd; font-size: 12.5px; }

/* ===== cột phải ===== */
.soan-tab { display: flex; border-bottom: 1px solid var(--s-vien); }
.soan-tab button { flex: 1; min-height: 46px; border: 0; background: transparent; border-bottom: 3px solid transparent; font-weight: 600; color: var(--s-phu); }
.soan-tab button[aria-selected="true"] { color: var(--s-chinh); border-bottom-color: var(--s-chinh); }
.soan-bang { flex: 1 1 auto; overflow-y: auto; padding: 12px; min-height: 0; }
.soan-dong { display: none; }
.soan-muc { margin: 0 0 14px; padding: 0 0 12px; border: 0; border-bottom: 1px solid var(--s-vien); }
.soan-muc:last-child { border-bottom: 0; }
.soan-muc > h3, .soan-muc > legend { margin: 0 0 8px; padding: 0; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--s-phu); }
.soan-truong { display: block; margin: 0 0 10px; }
.soan-truong > span { display: block; font-size: 13px; color: var(--s-phu); margin-bottom: 3px; }
.soan input[type=text], .soan input[type=url], .soan input[type=search], .soan input[type=number], .soan select, .soan textarea {
  width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--s-vien); background: var(--s-nen);
}
.soan textarea { resize: vertical; line-height: 1.45; }
.soan input:focus, .soan select:focus, .soan textarea:focus { border-color: var(--s-chinh); background: var(--s-nen2); }
.soan-hang { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.soan-hang > input[type=text], .soan-hang > textarea { flex: 1 1 auto; min-width: 0; }
.soan-hang .soan-nut { min-width: 44px; padding: 0; flex: 0 0 auto; }
.soan-tron { flex: 0 0 auto; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; cursor: pointer; }
.soan-tron input { width: 22px; height: 22px; min-height: 0; accent-color: var(--s-ok); margin: 0; cursor: pointer; }
.soan-muc-con { border: 1px solid var(--s-vien); border-radius: 12px; padding: 10px; margin: 0 0 10px; background: var(--s-nen); }
.soan-muc-con > .dau { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.soan-muc-con > .dau b { flex: 1; font-size: 13px; }
.soan-goi-y { font-size: 12.5px; color: var(--s-phu); margin: 4px 0 8px; }
.soan-goi-y.canh { color: var(--s-canh); }
.soan-doan { display: inline-flex; border: 1px solid var(--s-vien); border-radius: 10px; overflow: hidden; }
.soan-doan label { min-height: 44px; min-width: 64px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0 10px; background: var(--s-nen); }
.soan-doan input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.soan-doan label:has(input:checked) { background: var(--s-chinh); color: var(--s-chinh-chu); font-weight: 600; }
.soan-doan label:has(input:focus-visible) { outline: 3px solid var(--s-nhan); outline-offset: -3px; }
.soan-bang-o { overflow-x: auto; border: 1px solid var(--s-vien); border-radius: 10px; }
.soan-bang-o table { border-collapse: collapse; width: 100%; }
.soan-bang-o td, .soan-bang-o th { padding: 3px; }
.soan-bang-o input { min-width: 96px; min-height: 40px; }
.soan-xem-nho { width: 100%; max-height: 120px; object-fit: contain; border-radius: 8px; border: 1px solid var(--s-vien); background: #fff; margin-bottom: 6px; }
.soan-soat-ds { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.soan-soat-ds button { width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--s-vien); background: var(--s-nen); min-height: 44px; }
.soan-soat-ds button:hover { border-color: var(--s-chinh); }
.soan-soat-ds .chip { display: inline-block; padding: 0 8px; margin-right: 6px; border-radius: 99px; font-size: 12px; font-weight: 700; color: #fff; }
.soan-soat-ds .chip.do { background: var(--s-loi); }
.soan-soat-ds .chip.vang { background: #b97a00; }
.soan-soat-ds small { display: block; color: var(--s-phu); margin-top: 2px; }
.soan-rong { text-align: center; color: var(--s-phu); padding: 24px 8px; }

/* ===== bảng chọn nổi, thực đơn, thông báo ===== */
.soan-lop { position: fixed; inset: 0; z-index: 950; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(10,14,18,.6); }
.soan-hop-thoai {
  width: min(920px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--s-nen2); border: 1px solid var(--s-vien);
  border-radius: 16px; box-shadow: var(--s-bong); overflow: hidden; font-size: 15px; line-height: 1.45;
}
.soan-hop-thoai.hep { width: min(520px, 100%); }
.soan-hop-thoai * { box-sizing: border-box; }
.soan-hop-thoai button, .soan-hop-thoai input, .soan-hop-thoai select, .soan-hop-thoai textarea { font: inherit; color: inherit; }
.soan-hop-thoai input[type=text], .soan-hop-thoai input[type=url], .soan-hop-thoai input[type=search], .soan-hop-thoai select, .soan-hop-thoai textarea {
  width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--s-vien); background: var(--s-nen);
}
.soan-hop-thoai textarea { resize: vertical; }
.soan-hop-thoai > header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--s-vien); }
.soan-hop-thoai > header h2 { flex: 1; margin: 0; font-size: 18px; }
.soan-hop-thoai > .than { padding: 14px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.soan-hop-thoai > footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--s-vien); }
.soan-luoi { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.soan-the { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 8px; border-radius: 12px; border: 2px solid var(--s-vien); background: var(--s-nen); min-height: 44px; }
.soan-the:hover { border-color: var(--s-chinh); }
.soan-the.chon { border-color: var(--s-chinh); background: var(--s-nen-chon); }
.soan-the .xem { position: relative; aspect-ratio: 16/9; border-radius: 6px; overflow: hidden; background: #fff; border: 1px solid var(--s-vien); pointer-events: none; }
.soan-the .xem img { width: 100%; height: 100%; object-fit: cover; display: block; }
.soan-the .xem .ve { position: absolute; inset: 0; }
.soan-the b { font-size: 14px; }
.soan-the small { color: var(--s-phu); font-size: 12px; }
.soan-loc { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.soan-chip { min-height: 44px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--s-vien); background: var(--s-nen); }
.soan-chip[aria-pressed="true"] { background: var(--s-chinh); color: var(--s-chinh-chu); border-color: var(--s-chinh); }
.soan-nhom-tieu-de { margin: 14px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--s-phu); }
.soan-menu {
  position: fixed; z-index: 980; min-width: 220px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto; padding: 6px;
  background: var(--s-nen2); border: 1px solid var(--s-vien); border-radius: 12px; box-shadow: var(--s-bong); color: var(--s-chu);
  font: 15px/1.4 "Be Vietnam Pro", system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
}
.soan-menu button { display: flex; width: 100%; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 0; background: transparent; border-radius: 8px; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.soan-menu button:hover:not(:disabled), .soan-menu button:focus-visible { background: var(--s-nen-chon); }
.soan-menu button:disabled { opacity: .45; cursor: not-allowed; }
.soan-menu button.nguy { color: var(--s-loi); }
.soan-menu hr { border: 0; border-top: 1px solid var(--s-vien); margin: 4px 0; }
.soan-thong-bao { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 990; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(560px, calc(100vw - 24px)); pointer-events: none; }
.soan-tb { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: #20262c; color: #f3f1ea; box-shadow: var(--s-bong); font: 14.5px/1.4 "Be Vietnam Pro", system-ui, "Segoe UI", Tahoma, Arial, sans-serif; animation: soan-vao 200ms ease-out; }
.soan-tb.loi { background: #7a1e17; }
.soan-tb button { min-height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid #fff6; background: transparent; color: #fff; cursor: pointer; font: inherit; font-weight: 600; }
@keyframes soan-vao { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.soan-cho { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: soan-quay 800ms linear infinite; vertical-align: -3px; }
@keyframes soan-quay { to { transform: rotate(360deg); } }
.soan-bao { position: sticky; top: 0; z-index: 3; padding: 8px 12px; background: #fdecc8; color: #4a2f00; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.soan-hinh-luoi { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.soan-hinh-luoi button { aspect-ratio: 1; border-radius: 12px; border: 2px solid var(--s-vien); background: #fff; padding: 8px; min-height: 44px; }
.soan-hinh-luoi button:hover { border-color: var(--s-chinh); }
.soan-hinh-luoi svg { width: 100%; height: 100%; display: block; }

/* ===== máy tính bảng: ngăn kéo phải, dải trang ngang ===== */
.soan-nut-thuoc-tinh { display: none; }
@media (max-width: 1099px) {
  .soan-than { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "giua" "trai"; }
  .soan-trai { border-right: 0; border-top: 1px solid var(--s-vien); flex-direction: row; align-items: stretch; }
  .soan-ds { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 8px; gap: 8px; }
  .soan-th { flex: 0 0 132px; grid-template-columns: 1fr; }
  .soan-th .so { position: absolute; left: 8px; top: 6px; z-index: 2; padding: 0 5px; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; text-align: center; }
  .soan-th .nhan { grid-column: 1; }
  .soan-th.keo-truoc { box-shadow: -3px 0 0 0 var(--s-nhan); }
  .soan-th.keo-sau { box-shadow: 3px 0 0 0 var(--s-nhan); }
  .soan-them-trang { margin: 8px; align-self: center; flex: 0 0 auto; flex-direction: column; min-height: 72px; }
  .soan-phai {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 920; width: min(380px, 100vw); transform: translateX(105%);
    transition: transform 200ms ease; box-shadow: var(--s-bong);
  }
  .soan.mo-ngan .soan-phai { transform: none; }
  .soan-dong { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--s-vien); font-weight: 700; }
  .soan-nut-thuoc-tinh { display: inline-flex; }
  .soan-man-che { position: fixed; inset: 0; z-index: 915; background: rgba(0,0,0,.4); display: none; }
  .soan.mo-ngan .soan-man-che { display: block; }
}
/* ===== điện thoại: ngăn đáy ===== */
@media (max-width: 767px) {
  .soan-dau { padding: 6px 8px; gap: 4px; }
  .soan-ten { flex: 1 1 100px; font-size: 16px; }
  .soan-dau .chu-nut { display: none; }
  .soan-luu { min-width: 0; font-size: 12px; flex: 1 1 100%; order: 9; text-align: left; padding-left: 4px; }
  .soan-cc { padding: 4px 8px; }
  .soan-san { padding: 8px; }
  .soan-th { flex-basis: 108px; }
  .soan-phai {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 72vh; border-left: 0; border-radius: 18px 18px 0 0;
    transform: translateY(105%); padding-bottom: env(safe-area-inset-bottom);
  }
  .soan.mo-ngan .soan-phai { transform: none; }
  .soan-chan { padding: 4px 8px; }
  .soan-meo { display: none; }
  .soan-hop-thoai { max-height: 100%; border-radius: 14px; }
  .soan-luoi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .soan-lop { padding: 6px; align-items: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  .soan *, .soan-lop *, .soan-menu, .soan-tb { animation: none !important; transition: none !important; }
}

/* màn hình thấp: nhường chỗ cho sân khấu */
@media (max-width: 1099px) and (max-height: 700px) {
  .soan-cc .soan-nut { min-height: 44px; font-size: 12px; }
  .soan-cc .bieu-tuong { font-size: 16px; }
  .soan-th { flex-basis: 96px; }
  .soan-th .nhan span { display: none; }
  .soan-th .nhan { justify-content: flex-end; }
  .soan-them-trang { min-height: 56px; }
  .soan-chan { padding: 2px 8px; }
}

/* khung vẽ của bộ vẽ luôn lấp đầy hộp chứa, bỏ tỉ lệ tự đặt */
.soan-ve, .soan-th .ve, .soan-the .ve { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; aspect-ratio: auto !important; }

@media (max-width: 767px) { .soan-nut.nho, .soan-th .ba-cham { min-height: 44px; min-width: 44px; } }

.soan-vung.tran { border-color: #e0a800; border-style: solid; }
.soan-vung.tran .nhan-vung { display: block; }

/* ===== V2: bố cục không bị che, mọi thanh luôn thấy đủ ===== */
.soan-dau, .soan-bao, .soan-cc { flex: 0 0 auto; }
@media (min-width: 1100px) { .soan-than { grid-template-rows: minmax(0, 1fr); } }
.soan-cc { overflow-y: hidden; }
.soan-cc .soan-nut { min-height: 52px; }
.soan-hop { overflow: visible; outline: none; }
.soan-hop:focus-visible { box-shadow: 0 0 0 3px var(--s-nhan), 0 8px 40px rgba(0,0,0,.5); }
.soan-phu { touch-action: none; user-select: none; -webkit-user-select: none; }
.soan-tab { overflow-x: auto; scrollbar-width: thin; }
.soan-tab button { flex: 1 0 auto; padding: 0 12px; white-space: nowrap; }
.soan-chan { flex: 0 0 auto; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: thin; }
.soan-chan > * { flex: 0 0 auto; }
.soan-chan .soan-meo { flex: 1 1 auto; white-space: nowrap; }
.soan-vat-cc { display: inline-flex; gap: 4px; align-items: center; }
.soan-vat-cc[hidden] { display: none !important; }
.soan-vat-cc .soan-nut { background: #262d35; color: #e8e6df; border-color: #3a434d; }
.soan-vat-cc .ten-nut { font-size: 13px; }
@media (max-height: 760px) {
  .soan-dau { padding: 4px 10px; }
  .soan-cc { padding: 3px 10px; }
  .soan-chan { padding: 2px 10px; }
  .soan-san { padding: 10px; }
}
@media (max-width: 1099px) { .soan-nut-thuoc-tinh { display: inline-flex; } }
@media (max-width: 520px) { .soan-vat-cc .ten-nut { display: none; } }

/* ===== khung chọn, tay nắm, đường gióng ===== */
.soan-kh { position: absolute; pointer-events: none; border: 2px solid #2f7bff; border-radius: 1px; transform-origin: 50% 50%; z-index: 3; }
.soan-kh.phu-chon { border-style: dashed; border-width: 1.5px; }
.soan-kh.khoa { border-color: #8a8f98; border-style: dotted; }
.soan-kh.cat { border-color: #e0a800; border-width: 3px; }
.soan-nhom { position: absolute; pointer-events: none; border: 1.5px dashed #2f7bff; z-index: 2; }
.soan-ro { position: absolute; pointer-events: none; border: 2px solid rgba(47,123,255,.5); z-index: 2; transform-origin: 50% 50%; }
.soan-khoa-bieu { position: absolute; right: -4px; top: -22px; font-size: 14px; }
.soan-tay { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; background: #fff; border: 2px solid #2f7bff; border-radius: 3px; pointer-events: auto; touch-action: none; }
.soan-tay::after { content: ""; position: absolute; inset: -8px; }
@media (pointer: coarse) { .soan-tay { width: 18px; height: 18px; margin: -9px 0 0 -9px; } .soan-tay::after { inset: -10px; } }
.soan-kh.cat .soan-tay { background: #e0a800; border-color: #5a4200; border-radius: 1px; }
.soan-tay.t-nw { left: 0; top: 0; cursor: nwse-resize; } .soan-tay.t-n { left: 50%; top: 0; cursor: ns-resize; } .soan-tay.t-ne { left: 100%; top: 0; cursor: nesw-resize; }
.soan-tay.t-e { left: 100%; top: 50%; cursor: ew-resize; } .soan-tay.t-se { left: 100%; top: 100%; cursor: nwse-resize; } .soan-tay.t-s { left: 50%; top: 100%; cursor: ns-resize; }
.soan-tay.t-sw { left: 0; top: 100%; cursor: nesw-resize; } .soan-tay.t-w { left: 0; top: 50%; cursor: ew-resize; }
.soan-kh.hep .t-n, .soan-kh.hep .t-s { display: none; } .soan-kh.thap .t-e, .soan-kh.thap .t-w { display: none; }
.soan-tay-xoay { position: absolute; left: 50%; top: -34px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #2f7bff; border: 2px solid #fff; cursor: grab; pointer-events: auto; touch-action: none; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.soan-tay-xoay::after { content: ""; position: absolute; inset: -10px; }
@media (pointer: coarse) { .soan-tay-xoay { width: 22px; height: 22px; margin-left: -11px; top: -40px; } }
.soan-tay-cuong { position: absolute; left: 50%; top: -22px; width: 2px; height: 22px; margin-left: -1px; background: #2f7bff; }
.soan-gz { position: absolute; pointer-events: none; background: #ff3d8b; z-index: 4; }
.soan-gz.doc { top: 0; bottom: 0; width: 1px; } .soan-gz.ngang { left: 0; right: 0; height: 1px; }

/* ===== thẻ Vật, Chuyển động ===== */
.soan-luoi-so { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.soan-luoi-so .soan-truong { margin: 0 0 8px; }
.soan-luoi-nut { flex-wrap: wrap; }
.soan-truot input[type=range] { flex: 1 1 auto; min-height: 44px; accent-color: var(--s-chinh); padding: 0; }
.soan-so-nho { min-width: 64px; text-align: right; font-size: 13px; }
.soan-ds-hu { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.soan-hu-dong { display: flex; align-items: center; gap: 2px; padding: 2px 4px; border: 1px solid var(--s-vien); border-radius: 10px; background: var(--s-nen); }
.soan-hu-dong.dang-keo { opacity: .4; }
.soan-hu-dong.keo-truoc { box-shadow: 0 -3px 0 0 var(--s-nhan); } .soan-hu-dong.keo-sau { box-shadow: 0 3px 0 0 var(--s-nhan); }
.soan-hu-tay { cursor: grab; color: var(--s-phu); padding: 0 4px; }
.soan-hu-ten { flex: 1 1 auto; min-width: 0; min-height: 44px; text-align: left; border: 0; background: transparent; overflow: hidden; }
.soan-hu-ten small { display: block; color: var(--s-phu); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soan-hu-dong .soan-nut { min-width: 36px; padding: 0 6px; }
