/* Phòng ảnh — đo hẹp thủ công WASID (thước kẹp, kính lúp, bảng kết quả) */
.studio .side { padding: 10px 12px; }
.studio .side .sbox { border-bottom: 1px solid var(--line); padding: 2px 0 10px; margin-bottom: 8px; }
.studio .side .sbox:last-child { border-bottom: 0; }
.studio .side .sbox > summary { cursor: pointer; font-weight: 650; font-size: 13.5px; padding: 6px 0; list-style: none;
  display: flex; align-items: center; gap: 6px; user-select: none; }
.studio .side .sbox > summary::-webkit-details-marker { display: none; }
.studio .side .sbox > summary::before { content: "▸"; color: var(--ink-3, #889); font-size: 11px; transition: transform .15s; }
.studio .side .sbox[open] > summary::before { transform: rotate(90deg); }
.studio .side .sbody > * + * { margin-top: 6px; }
/* thư viện ảnh: xem trước cỡ lớn phủ khung ảnh + lưới nhỏ 2 cột ở khung phải */
/* khung ảnh + dải chú giải ở rìa dưới (không đè lên ảnh) */
.studio .stage-col { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #0b0f11; }
.studio .stage-col > .stage { flex: 1; min-height: 0; }
.studio .legend-bar { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 8px 14px;
  min-height: 64px;                                   /* đủ 2 dòng: khung ảnh không co giật khi thêm số đo */
  max-height: 34%; overflow-y: auto;
  background: #0b0f11; border-top: 1px solid #22303a; color: #cfdde0; font-size: 13.5px; }
.studio .legend-bar .lg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 20px; }
.studio .legend-bar .lg-notes { gap: 4px 22px; padding-top: 4px; border-top: 1px dashed #22303a; }
.studio .legend-bar .lg-nitem { display: inline-flex; align-items: center; gap: 6px; }
.studio .lg-arrow, .studio .narrow { display: inline-flex; align-items: center; color: inherit; }
.studio .lg-arrow i, .studio .narrow i { display: inline-block; width: 18px; height: 2px; background: currentColor; }
.studio .lg-arrow b, .studio .narrow b { width: 0; height: 0; border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent;
  border-left: 8px solid currentColor; }
.studio .legend-bar .lg-item { display: inline-flex; align-items: center; gap: 7px; }
.studio .legend-bar .lg-item i { display: inline-block; width: 24px; height: 2px; }
.studio .legend-bar .lg-wasid { color: #fff; }
.studio .legend-bar .lg-wasid b { color: #ff6b5f; font-size: 15.5px; }
.studio .legend-bar .lg-note { color: #8a9ca1; font-size: 12px; margin-left: auto; }
.studio .legend-bar .lg-empty { color: #8a9ca1; font-size: 12.5px; }
.studio .gallery { position: absolute; inset: 0; z-index: 4; background: #0e1417; overflow: auto; padding: 0 16px 16px; color: #dfe; }
.studio .gal-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #0e1417; padding: 12px 0 8px; font-size: 14px; }
.studio .gal-head .gal-sub { color: #9fb0b5; font-size: 12.5px; }
.studio .gal-head .spacer { flex: 1; }
.studio .gal-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.studio .chip { border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); border-radius: 999px; padding: 3px 10px;
  font-size: 12.5px; cursor: pointer; }
.studio .chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.studio .gallery .chip { border-color: #33444a; background: #152025; color: #cfe; }
.studio .gallery .chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.studio .gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.studio .gal-card { display: block; width: 100%; background: #152025; border: 2px solid transparent; border-radius: 10px; padding: 6px;
  cursor: pointer; text-align: left; color: #dfe; font: inherit; }
.studio .gal-card:hover { border-color: color-mix(in srgb, var(--brand) 60%, transparent); }
.studio .gal-card.on { border-color: var(--brand); }
.studio .gal-img { position: relative; aspect-ratio: 4 / 3; background: #000; border-radius: 7px; overflow: hidden; display: grid; place-items: center; }
.studio .gal-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.studio .gal-noimg { font-size: 11px; color: #7d8c88; }
.studio .gal-badge { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.72); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.studio .gal-cap { font-size: 12.5px; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio .gal-grp { color: #7fe0c0; font-weight: 650; }
.studio .gal-empty { color: #9fb0b5; padding: 30px 4px; }
.studio .src-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 330px; overflow: auto; padding-right: 2px; }
.studio .src-grid .gal-card.mini { background: var(--panel-2); color: var(--ink); padding: 4px; border-radius: 8px; }
.studio .src-grid .gal-card.mini .gal-cap { font-size: 11px; margin-top: 3px; }
.studio .src-grid .gal-card.mini .gal-grp { color: var(--brand); }
.studio .src-grid .gal-card.mini.on { border-color: var(--brand); background: var(--brand-soft); }
.studio .sep-line { height: 1px; background: var(--line); margin: 4px 0; }

.studio .stage .tool-hint { position: absolute; right: 10px; bottom: 10px; max-width: min(560px, 62%); font-size: 12px; line-height: 1.4;
  color: #fff3c4; background: rgba(0,0,0,.6); padding: 6px 10px; border-radius: 8px; pointer-events: none; }
.studio .stage .loupe { position: absolute; top: 10px; left: 10px; width: 150px; height: 150px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85); box-shadow: 0 4px 18px rgba(0,0,0,.6); pointer-events: none; z-index: 3; }

/* các mục đo */
.studio .mrow { --c: var(--brand); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 9px;
  padding: 7px 9px; cursor: pointer; background: var(--panel); }
.studio .mrow.on { background: color-mix(in srgb, var(--c) 7%, var(--panel)); }
.studio .mrow.active { border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 30%, transparent); }
.studio .mrow .mchk { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.studio .mrow .mchk input { width: 17px; height: 17px; margin: 0; accent-color: var(--c); }
.studio .mrow .swatch { width: 18px; height: 3px; border-radius: 2px; background: var(--c); flex: none; }
.studio .mrow .mline { display: flex; align-items: center; gap: 6px; margin: 4px 0 0 25px; font-size: 13px; min-height: 26px; }
.studio .mrow .mline .mval { flex: 1; }
.studio .mrow .mline .btn svg.ico { width: 14px; height: 14px; }
.studio .mrow > .small { margin: 4px 0 0 25px; }
.studio .mrow.wasid { --c: #ffffff; border-left-color: var(--ink-2, #445); cursor: default; }
.studio .mrow.cal { --c: #ffd60a; }
.studio .wasid-box { margin: 6px 0 0 25px; }
.studio .wasid-box > * + * { margin-top: 4px; }
.studio .wasid-pct { font-size: 30px; font-weight: 750; line-height: 1.1; color: var(--bad); display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.studio .wasid-pct span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.studio .tools { overflow-x: hidden; }
@media (max-width: 1100px) {
  .studio .stage .tool-hint { max-width: 90%; left: 10px; right: auto; bottom: 40px; }
  .studio .tools { padding: 8px 4px; align-items: center; }
  .studio .tools button { width: 44px; }
}

/* ghi chú ảnh (mũi tên màu) + ước tính kích thước thật */
.studio .mrow.note { cursor: default; }
.studio .mrow.note .nhead { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.studio .mrow.note .narrow { color: var(--c); }
.studio .mrow.note .nno { color: var(--c); font-size: 13.5px; }
.studio .mrow.note input[type=text] { width: 100%; }
.studio .mrow.note .btn.icon.sm { padding: 2px; height: 22px; width: 22px; min-height: 0; }
.studio .size-modes { margin-bottom: 4px; }
.studio .size-ok { font-size: 12.5px; color: var(--ok); }
.studio .size-est { font-size: 12.5px; color: var(--warn); }

/* thanh khung (cine / video): phát, khung trước / sau; trạng thái tệp mở từ máy */
.studio .stage .framebar .fb-btn { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 6px; min-width: 30px; height: 26px; cursor: pointer; font-size: 13px; }
.studio .stage .framebar .fb-btn:hover { background: rgba(255,255,255,.25); }
.studio .stage .framebar .fb-lab { white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 120px; }
.studio .gal-status { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.72); color: #fff3c4; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.studio .gal-badge.kept { left: 6px; right: auto; background: rgba(48,209,88,.85); }
.studio .gal-card.err { opacity: .6; }
.studio .gal-noimg { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; text-align: center; }

/* Thêm DICOM thông minh */
.dcm-smart textarea { width: 100%; }
.dcm-smart .dcm-cands { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; padding-right: 4px; }
.dcm-smart .dcm-cand { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; cursor: pointer; background: var(--panel); }
.dcm-smart .dcm-cand.ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }
.dcm-smart .dcm-cand.bad { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); opacity: .8; }
.dcm-smart .dcm-cand input { margin-top: 3px; }
.dcm-smart .dcm-why { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.dcm-smart .dcm-why span { font-size: 11.5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }

/* hàng đợi: tệp được ưu tiên (nháy đúp) */
.studio .gal-card.pri { border-color: var(--warn); box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 35%, transparent); }

/* hộp hỏi giữ / bỏ tệp cũ khi mở tệp mới */
.keep-ask ul { margin: 0 0 4px 18px; padding: 0; }
.keep-ask li { margin: 2px 0; }
.keep-ask li.warn { color: var(--warn); font-weight: 600; }
.keep-ask .keep-rem { display: flex; gap: 6px; align-items: center; }

/* ---- trình chỉnh ảnh chuyên nghiệp: cột công cụ dài hơn, chỉnh ảnh, vẽ, trợ lý AI, ghép ảnh */
.studio .tools { overflow-y: auto; scrollbar-width: none; }
.studio .tools::-webkit-scrollbar { display: none; }
.studio .tools button { height: 38px; flex: none; }
.studio .adj-hist { display: block; width: 100%; height: 64px; border-radius: 6px; background: #0b0f11; border: 1px solid var(--line); }
.studio .side .slider-row { grid-template-columns: 96px 1fr 40px; margin-bottom: 2px; }
.studio .side .chip.ai { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 35%, transparent); }
.studio .side .chip.ai svg { width: 14px; height: 14px; vertical-align: -2px; }
.studio .side .btn.icon { padding: 4px 7px; }
.studio .side .btn.icon svg { width: 17px; height: 17px; }
.studio .crop-box, .studio .draw-style { background: var(--panel-2); border-radius: 8px; padding: 8px; }
.studio .draw-tools, .studio .ai-btns { display: flex; flex-wrap: wrap; gap: 5px; }
.studio .swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.studio .swatches .sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(0,0,0,.35); cursor: pointer; padding: 0; }
.studio .swatches .sw.on { outline: 2px solid var(--brand); outline-offset: 2px; }
.studio textarea.draw-text { width: 100%; resize: vertical; }
.studio .obj-list { display: flex; flex-direction: column; gap: 1px; max-height: 190px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.studio .obj-list .obj { display: flex; align-items: center; gap: 8px; padding: 2px 4px 2px 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.studio .obj-list .obj:hover { background: var(--panel-2); }
.studio .obj-list .obj.on { background: var(--brand-soft); }
.studio .obj-list .obj i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); flex: none; }
.studio .obj-list .obj span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio .ai-ask { display: flex; gap: 6px; align-items: flex-end; }
.studio .ai-ask textarea { flex: 1; min-width: 0; resize: vertical; }
.studio .ai-res .ai-answer { white-space: pre-wrap; line-height: 1.5; }
.studio .ai-cap { background: var(--panel-2); border-radius: 6px; padding: 6px 8px; }
.studio .tray { display: flex; flex-direction: column; gap: 4px; }
.studio .tray-item { display: grid; grid-template-columns: 54px 14px minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.studio .tray-item img { width: 54px; height: 40px; object-fit: contain; background: #000; border-radius: 4px; }
.studio .tray-item input { font-size: 12px; padding: 3px 6px; min-width: 0; }

/* ---- Lấy dữ liệu từ PACS: ô tìm, danh sách người / lần chụp; thanh "Chụp ảnh" từ cửa sổ xem PACS */
.pacs-find { gap: 10px; }
.pacs-find .pf-bar { display: flex; gap: 8px; }
.pacs-find .pf-q { flex: 1; font-size: 16px; padding: 10px 12px; }
.pacs-find .pf-top > * + * { margin-top: 6px; }
.pacs-find .pf-hint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pacs-find .pf-bridge { margin-left: auto; font-size: 12px; }
.pacs-find .pf-bridge.ok { color: var(--ok); }
.pacs-find .pf-bridge.bad { color: var(--bad); }
.pacs-find .pf-filters, .pacs-find .pf-nc { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.pacs-find .pf-busy { padding: 26px 0; text-align: center; color: var(--ink-2, #667); }
.pacs-find .pf-tips > div + div { margin-top: 4px; }
.pacs-find .pf-sum { margin-bottom: 6px; }
.pacs-find .pf-cols { display: grid; grid-template-columns: minmax(230px, 320px) minmax(0, 1fr); gap: 12px; height: min(56vh, 560px); }
.pacs-find .pf-people, .pacs-find .pf-studies { overflow-y: auto; overflow-x: hidden; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.pacs-find .pf-person { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 7px 9px; cursor: pointer; color: inherit; }
.pacs-find .pf-person:hover { background: var(--panel-2); }
.pacs-find .pf-person.on { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.pacs-find .pf-name { font-weight: 650; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pacs-find .pf-m { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 99px; background: var(--panel-2); color: var(--ink-2, #667); }
.pacs-find .pf-m.ok { color: var(--ok); }
.pacs-find .pf-m.warn { color: var(--warn); }
.pacs-find .pf-studies { padding: 6px 8px; }
.pacs-find .pf-sh { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 2px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.pacs-find .pf-study { display: grid; grid-template-columns: 112px 74px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 2px; border-bottom: 1px dashed var(--line); font-size: 13px; }
.pacs-find .pf-study:last-child { border-bottom: 0; }
.pacs-find .pf-mods { display: flex; gap: 3px; flex-wrap: wrap; }
.pacs-find .pf-mod { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--brand-soft); color: var(--brand); }
.pacs-find .pf-act { display: flex; gap: 4px; }
.pacs-find .pf-foot { margin-top: 8px; }
@media (max-width: 760px) { .pacs-find .pf-cols { grid-template-columns: 1fr; height: auto; } .pacs-find .pf-study { grid-template-columns: 1fr auto; } }
.studio .capbar { position: absolute; left: 50%; transform: translateX(-50%); top: 10px; z-index: 3; display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 20px); padding: 6px 8px 6px 12px; border-radius: 12px; background: rgba(14, 22, 26, .92); color: #e6f0f2;
  box-shadow: 0 6px 22px rgba(0,0,0,.35); font-size: 13px; }
.studio .capbar[hidden] { display: none; }
.studio .capbar .cap-lab { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.studio .capbar .cap-dot { width: 9px; height: 9px; border-radius: 50%; background: #8a9ca1; flex: none; }
.studio .capbar .cap-dot.on { background: #ff453a; box-shadow: 0 0 0 3px rgba(255,69,58,.25); }
.studio .capbar .btn.ghost { color: #cfe; }
.studio .stage .framebar:not([hidden]) ~ .capbar { top: 56px; }
.pacs-find .pf-filter { width: 100%; margin-bottom: 4px; font-size: 13px; padding: 5px 8px; position: sticky; top: 0; z-index: 1; }
