:root {
  --bg: #0f1012; --bg2: #16171a; --bg3: #1d1f23; --line: #2a2c31; --line2: #34373d;
  --text: #e9e7e3; --muted: #8d8f95; --dim: #5d6067;
  --accent: #f0a04b; --accent2: #ffbd73; --accentInk: #1b1206;
  --ok: #7fcf9a; --warn: #e6b25c;
  --r: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 13px; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }

.top { height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: .2px; }
.out-dir { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.out-dir b { font-weight: 600; color: var(--accent2); }
.save-state { font-size: 11px; color: var(--muted, #8a8f98); margin-right: 4px; white-space: nowrap; }
.save-state.ok::before { content: '●'; color: #3fb950; margin-right: 4px; }
.save-state.saving::before { content: '●'; color: #d29922; margin-right: 4px; }
.save-state.err { color: #f85149; }
.asset.missing { opacity: .45; }
.lost-conn { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 9999; max-width: 640px; padding: 12px 16px;
  background: #3a1214; color: #ffd9d9; border: 1px solid #f85149; border-radius: 8px; font-size: 13px; line-height: 1.5; box-shadow: 0 8px 30px #000a; }
.skin-preset { width: 100%; margin: 6px 0 2px; padding: 6px 8px; background: #1b1d22; color: inherit; border: 1px solid #333842; border-radius: 6px; font: inherit; }
.modal p.path { font-family: Consolas, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; padding: 6px 8px; word-break: break-all; color: #d9d6d0; }
.brand-logo { display: flex; align-items: center; }
.app-icon { width: 26px; height: 26px; border-radius: 6px; background: #fff; display: block; box-shadow: 0 0 0 1px #ffffff22; }
.brand-logo img { height: 30px; width: auto; display: block; image-rendering: auto; }
.brand-sep { width: 1px; height: 22px; background: var(--line2); margin: 0 4px; }
.brand small { color: var(--muted); font-weight: 400; font-size: 12px; }
.logo { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(from 200deg, #f0a04b, #e0526b, #6a7bff, #3fc1b0, #f0a04b); box-shadow: 0 0 0 3px #f0a04b22; }
.actions { display: flex; gap: 8px; }

.btn { border: 1px solid var(--line2); background: var(--bg3); padding: 7px 14px; border-radius: 8px; transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap; }
.btn:hover { background: #26282d; border-color: #44474e; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg3); }
.btn.primary { background: var(--accent); color: var(--accentInk); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.active { border-color: var(--accent); color: var(--accent2); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.wide { width: 100%; padding: 9px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-size: 12px; }
.link:hover { color: var(--accent2); text-decoration: underline; }

.layout { display: grid; grid-template-columns: 300px 1fr 340px; height: calc(100% - 54px); }

/* Thư viện */
.lib { border-right: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; min-height: 0; }
.lib-head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.lib-title { font-weight: 600; }
.lib-title span { color: var(--muted); font-weight: 400; }
.lib-head input { background: var(--bg); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 10px; outline: none; }
.lib-head input:focus { border-color: var(--accent); }
.lib-tools { display: flex; justify-content: space-between; }
.lib-list { overflow-y: auto; flex: 1; padding: 6px 8px 20px; }
.grp { margin-top: 4px; }
.grp-h { width: 100%; display: flex; align-items: center; gap: 6px; text-align: left; background: none; border: 0; padding: 7px 6px; border-radius: 6px; color: var(--text); font-weight: 550; }
.grp-h:hover { background: var(--bg3); }
.grp-h .chev { width: 10px; color: var(--muted); transition: transform .15s; }
.grp.open .grp-h .chev { transform: rotate(90deg); }
.grp-h .n { margin-left: auto; color: var(--dim); font-weight: 400; font-size: 11px; }
.grp-h .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid { display: none; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px 2px 8px; }
.grp.open > .grid { display: grid; }
.grp-empty { display: none; padding: 2px 8px 10px 22px; line-height: 1.5; }
.grp.open > .grp-empty { display: block; }
/* nhóm lớn "1000 Preset" chứa các bộ con */
.grp.super { margin-top: 8px; border-top: 1px solid var(--line, #2a2d33); padding-top: 4px; }
.grp.super > .grp-h { font-weight: 650; }
.grp.super > .sub { display: none; margin-left: 10px; padding-left: 4px; border-left: 1px solid var(--line, #2a2d33); }
.grp.super.open > .sub { display: block; }
.tile { position: relative; background: var(--bg3); border: 1px solid transparent; border-radius: 7px; padding: 0; overflow: hidden; text-align: left; }
.tile:hover { border-color: var(--line2); }
.tile.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile canvas, .tile .ph { display: block; width: 100%; aspect-ratio: 3 / 2; background: #22242a; }
.tile .ph { background: linear-gradient(135deg, #24262c, #1b1d21); }
.tile .nm { display: block; padding: 4px 6px 5px; font-size: 11px; color: #cfcdc8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .badge { position: absolute; top: 4px; left: 4px; font-size: 9px; padding: 1px 5px; border-radius: 4px; background: #000a; color: var(--accent2); letter-spacing: .3px; }

/* Khung xem */
.viewer { position: relative; background: #0a0a0b; display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden;
  background-image: radial-gradient(circle at 50% 40%, #16171a 0, #0a0a0b 70%); }
.viewer.drag { outline: 2px dashed var(--accent); outline-offset: -10px; }
#cv { display: none; max-width: 100%; max-height: 100%; box-shadow: 0 10px 40px #0008; }
.viewer.has #cv { display: block; }
.viewer.has .empty { display: none; }
.empty { text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); font-weight: 550; font-size: 18px; margin: 14px 0 6px; }
.drop-icon { width: 64px; height: 64px; margin: 0 auto; border: 2px dashed var(--line2); border-radius: 16px; position: relative; }
.drop-icon::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; color: var(--accent); }
.split-line { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 6px #000a; cursor: ew-resize; }
.split-line::before { content: ""; position: absolute; top: 50%; left: -13px; width: 28px; height: 28px; margin-top: -14px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px #0008; }
.split-line span { position: absolute; top: 12px; font-size: 11px; padding: 2px 7px; background: #000b; border-radius: 4px; white-space: nowrap; }
.split-line span:first-child { right: 8px; } .split-line span:last-child { left: 8px; }
.viewer-info { position: absolute; left: 12px; bottom: 10px; color: var(--muted); font-size: 11px; background: #0009; padding: 3px 8px; border-radius: 5px; }
.viewer-info:empty { display: none; }
.zoom-badge { position: absolute; right: 12px; bottom: 10px; color: var(--muted); font-size: 11px; background: #0009; padding: 3px 8px; border-radius: 5px; pointer-events: none; }
.zoom-badge.on { color: var(--accent2); }
.viewer.zoomed #cv { cursor: grab; }
.viewer.panning #cv { cursor: grabbing; }
#busy { position: absolute; inset: 0; background: #0009; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 5; }
.spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff2; border-top-color: var(--accent); animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* Bảng điều khiển */
.panel { border-left: 1px solid var(--line); background: var(--bg2); display: flex; flex-direction: column; min-height: 0; }
.panel-scroll { flex: 1; overflow-y: auto; padding: 10px 12px 18px; }
.panel-foot { display: flex; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--bg2); }
.panel-foot .btn { flex: 1; padding: 6px 8px; }
.panel-foot #btnRedo { flex: 0 0 40px; }
.hist-box { padding: 8px 12px 6px; border-bottom: 1px solid var(--line); background: #121316; }
.hist-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; }
.clip { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 9px solid #3a3d44; }
.clip.on { border-bottom-color: #fff; }
#hist { width: 100%; height: 92px; display: block; background: #0b0c0e; border-radius: 6px; }

/* Các mục kiểu Lightroom */
.dev-panel { margin-top: 2px; }
.dev-sec { border-top: 1px solid var(--line); }
.dev-head { display: flex; align-items: center; gap: 8px; padding: 9px 2px; cursor: pointer; user-select: none; }
.dev-head:hover .ttl { color: #fff; }
.dev-head .ttl { flex: 1; font-weight: 600; font-size: 12.5px; color: #d9d6d0; }
.dev-head .ttl small { margin-left: 7px; font-weight: 400; color: var(--dim); font-size: 11px; }
.dev-head .eye { width: 22px; height: 16px; border: 0; padding: 0; background: none; position: relative; opacity: .75; }
.dev-head .eye::before { content: ""; position: absolute; inset: 3px 3px; border: 1.5px solid #cfcbc4; border-radius: 50% / 60%; }
.dev-head .eye::after { content: ""; position: absolute; left: 8px; top: 5px; width: 6px; height: 6px; border-radius: 50%; background: #cfcbc4; }
.dev-sec.off .eye { opacity: .35; }
.dev-sec.off .eye::before { border-style: dashed; }
.dev-sec.off .ttl { color: var(--dim); text-decoration: line-through; }
.dev-head .dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.dev-sec.changed .dot { background: var(--accent); }
.dev-head .rs { border: 0; background: none; color: var(--dim); padding: 0 4px; font-size: 14px; visibility: hidden; }
.dev-sec.changed .rs { visibility: visible; }
.dev-head .rs:hover { color: var(--accent2); }
.dev-head .chev { color: var(--dim); font-size: 10px; transition: transform .15s; }
.dev-sec.open .chev { transform: rotate(-90deg); }
.dev-body { display: none; padding: 0 2px 12px; }
.dev-sec.open .dev-body { display: block; }
.dev-group { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 14px 0 4px; }
.seg { display: flex; align-items: center; gap: 4px; margin: 6px 0 10px; font-size: 12px; }
.seg span { color: var(--muted); margin-right: auto; }
.seg button { border: 1px solid var(--line2); background: transparent; padding: 4px 10px; border-radius: 6px; font-size: 12px; color: #cfcbc4; }
.seg button.on { background: #ffffff14; border-color: #ffffff40; color: #fff; }
.seg.small button { padding: 3px 8px; }
.seg button.has::after { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-left: 5px; vertical-align: middle; }
.seg.small button[style] { border-bottom: 2px solid var(--c); }
.curve-cv { width: 100%; aspect-ratio: 1; display: block; border-radius: 6px; cursor: crosshair; touch-action: none; }
.curve-tip { font-size: 10.5px; color: var(--dim); margin: 5px 0 0; }
.wheels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.wheel-cell { text-align: center; }
.wheel-cell:first-child { grid-column: 1 / -1; }
.wheel-cell:first-child .wheel { width: 62%; }
.wheel-lbl { font-size: 11.5px; color: #c9c6c0; margin-bottom: 4px; }
.wheel-cell.changed .wheel-lbl { color: var(--accent2); }
.wheel { width: 100%; aspect-ratio: 1; cursor: crosshair; touch-action: none; display: block; margin: 0 auto; }
.wheel-info { font-size: 10.5px; color: var(--dim); margin: 3px 0 -4px; }
.wheel-cell .sl { text-align: left; }
.sl-top input.v { width: 46px; background: transparent; border: 1px solid transparent; border-radius: 4px; text-align: right; color: var(--muted); font-size: 12px; padding: 0 3px; font-variant-numeric: tabular-nums; }
.sl-top input.v:hover { border-color: var(--line2); }
.sl-top input.v:focus { border-color: var(--accent); color: #fff; outline: none; }
.card { background: var(--bg3); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 10px; }
.card h3 { margin: 0 0 10px; font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: #cfcbc4; display: flex; justify-content: space-between; align-items: center; }
.card h3 .link { text-transform: none; letter-spacing: 0; font-weight: 400; }
.card.match { border-color: #f0a04b55; background: linear-gradient(180deg, #2a2118 0, var(--bg3) 120px); }
.ref-box { border: 1.5px dashed #5b4a36; border-radius: 9px; min-height: 120px; display: grid; place-items: center; cursor: pointer; overflow: hidden; position: relative; background: #0c0c0d55; }
.ref-box:hover, .ref-box.drag { border-color: var(--accent); }
.ref-box img { width: 100%; max-height: 190px; object-fit: contain; display: block; }
.ref-empty { color: var(--muted); text-align: center; padding: 14px; line-height: 1.5; }
.palette { display: flex; height: 18px; border-radius: 5px; overflow: hidden; margin-top: 8px; }
.palette i { flex: 1; }
#btnMatch { margin-top: 10px; }
.ctl-group { margin-top: 12px; }
.row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: var(--ok); font-size: 12px; gap: 8px; }
.preset-name { color: var(--text); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); font-size: 12px; }
.warn { color: var(--warn); font-size: 11px; margin-bottom: 8px; }
.warn:empty { display: none; }

.sl { margin: 9px 0; }
.sl-top { display: flex; justify-content: space-between; font-size: 12px; color: #c9c6c0; margin-bottom: 3px; }
.sl-top .v { color: var(--muted); font-variant-numeric: tabular-nums; cursor: text; min-width: 34px; text-align: right; }
.sl input[type=range] { width: 100%; -webkit-appearance: none; appearance: none; height: 16px; background: transparent; margin: 0; }
.sl input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: var(--trk, #3a3d44); }
.sl input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #eee; margin-top: -5px; border: 0; box-shadow: 0 1px 3px #000a; }
.sl input[type=range]:hover::-webkit-slider-thumb { background: var(--accent2); }
.sl.temp { --trk: linear-gradient(90deg, #4a7bd8, #d8c24a); }
.sl.tint { --trk: linear-gradient(90deg, #4ac06a, #c04ab8); }
.sl.changed .sl-top span:first-child { color: var(--accent2); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #24262b; border: 1px solid var(--line2); padding: 10px 16px; border-radius: 9px; box-shadow: 0 8px 30px #000a; z-index: 20; max-width: 70vw; display: flex; gap: 14px; align-items: center; }

.step { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--accent); color: var(--accentInk); font-style: normal; font-size: 10.5px; font-weight: 700; margin-right: 7px; vertical-align: 1px; }
.muted.small { font-size: 11.5px; margin: -4px 0 10px; line-height: 1.45; }
.chk { display: flex; align-items: center; gap: 7px; margin: 9px 0 2px; font-size: 12px; color: #c9c6c0; cursor: pointer; }
.chk input { accent-color: var(--accent); }
.base-ctl { margin-top: 8px; }
.base-ctl summary { cursor: pointer; font-size: 12px; color: var(--muted); padding: 4px 0; }
.base-ctl summary:hover { color: var(--text); }
.base-ctl.changed summary { color: var(--accent2); }

.sl.skinhue { --trk: linear-gradient(90deg, #d97a8a, #d9a07a, #d9bf6a); }
.switch { position: relative; width: 34px; height: 19px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #3a3d44; border-radius: 19px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 15px; height: 15px; border-radius: 50%; background: #ddd; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(15px); background: #fff; }
.skin-info { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; font-size: 12px; color: var(--muted); }
.skin-info i { width: 34px; height: 22px; border-radius: 5px; border: 1px solid #ffffff22; }
.skin-info small { margin-left: auto; }
.row-2 { display: flex; justify-content: space-between; align-items: center; }

.analysis { margin-top: 10px; border: 1px solid #ffffff12; border-radius: 8px; padding: 6px 9px 8px; background: #0c0c0d55; }
.analysis summary { cursor: pointer; font-size: 12px; color: #d9cbb8; padding: 2px 0; }
.an-grid { display: grid; grid-template-columns: 1.05fr 1fr 1fr; gap: 4px 8px; font-size: 11.5px; margin-top: 8px; align-items: center; }
.an-h { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
.an-l { color: var(--muted); }
.an-grid i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -3px; margin-right: 5px; border: 1px solid #ffffff22; }
.an-grid .dim { color: var(--dim); }
.an-plan { font-size: 11.5px; color: #c9c6c0; margin-top: 9px; line-height: 1.45; }
.an-plan ul { margin: 3px 0 0; padding-left: 16px; }

/* Dải ảnh (quản lý asset) */
.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.center .viewer { flex: 1; min-height: 0; }
.strip { border-top: 1px solid var(--line); background: var(--bg2); flex: none; }
.strip-bar { display: flex; align-items: center; gap: 12px; padding: 6px 12px; font-size: 12px; white-space: nowrap; overflow: hidden; }
.strip-title { color: var(--muted); }
.strip-title b { color: var(--text); font-weight: 600; }
.strip-title #stripSel { color: var(--accent2); margin-left: 6px; }
.strip-bar .sep { width: 1px; height: 14px; background: var(--line2); }
.strip-bar .link:disabled { color: var(--dim); cursor: default; text-decoration: none; }
.strip-bar .link.danger { color: #e7837b; }
.strip-hint { margin-left: auto; color: var(--dim); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.strip-list { display: flex; gap: 8px; overflow-x: auto; padding: 4px 12px 10px; scroll-behavior: smooth; }
.asset { position: relative; flex: none; width: 128px; border-radius: 7px; background: var(--bg3); border: 2px solid transparent; padding: 0; overflow: hidden; text-align: left; }
.asset:hover { border-color: var(--line2); }
.asset.sel { border-color: #6aa7ff; }
.asset.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.asset img, .asset .ph { display: block; width: 100%; height: 80px; object-fit: cover; background: #22242a; }
.asset .ph { display: grid; place-items: center; color: var(--dim); font-size: 11px; }
.asset .nm { display: block; padding: 3px 6px 4px; font-size: 10.5px; color: #cfcbc4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset .tag { position: absolute; top: 4px; left: 4px; font-size: 9px; padding: 1px 5px; border-radius: 4px; background: #000a; color: var(--accent2); letter-spacing: .3px; }
.asset .ed { position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px #000a; display: none; }
.asset.edited .ed { display: block; }
.asset.flash { animation: assetFlash 1.6s ease-out; }
@keyframes assetFlash { 0%, 30% { box-shadow: 0 0 0 3px var(--accent), 0 0 18px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.asset .x { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: #000b; color: #fff; font-size: 12px; line-height: 18px; text-align: center; display: none; padding: 0; }
.asset:hover .x { display: block; }
.asset:hover .ed { display: none; }
.asset .chk { position: absolute; bottom: 24px; left: 5px; width: 16px; height: 16px; border-radius: 4px; background: #6aa7ff; color: #fff; font-size: 11px; line-height: 16px; text-align: center; display: none; }
.asset.sel .chk { display: block; }

.light-info { display: flex; gap: 9px; align-items: center; font-size: 11.5px; color: #c9c6c0; background: #0c0c0d66; border: 1px solid #ffffff10; border-radius: 8px; padding: 7px 9px; margin: 0 0 9px; line-height: 1.4; }
.light-info i { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1px solid #ffffff30; }
.light-info b { color: var(--text); }
.light-info small { color: var(--muted); display: block; }
.row-btns { display: flex; gap: 8px; }
.row-btns .btn { flex: 1; padding: 8px; }
.row-btns .btn.on { border-color: var(--accent); color: var(--accent2); }
.viewer.picking #cv { cursor: crosshair; }
.viewer.healing #cv { cursor: cell; }
.viewer.brushing #cv { cursor: none; }
.heal-fix { margin-top: 10px; border: 1px solid var(--line2); border-radius: 8px; padding: 8px; background: #ffffff06; }
.fix-title { font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.fix-title small { font-weight: 400; color: var(--muted); }
.fix-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.fix-tools.three { grid-template-columns: 1fr 1fr 1fr; }
.fix-tools.three button { grid-template-columns: 1fr; grid-template-rows: auto auto auto; justify-items: center; text-align: center; row-gap: 2px; }
.fix-tools.three button i { grid-row: auto; }
#skinFix { margin: 8px 0 10px; }
.fix-tools button { display: grid; grid-template-columns: 22px 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center; text-align: left;
  border: 1px solid var(--line2); background: transparent; color: #cfcbc4; border-radius: 6px; padding: 6px 7px; cursor: pointer; }
.fix-tools button:hover { background: #ffffff0d; }
.fix-tools button.on { background: #ffb02022; border-color: #ffb020; color: #fff; }
.fix-tools button i { grid-row: 1 / 3; width: 20px; height: 20px; border-radius: 50%; position: relative; }
.fix-tools button b { font-size: 12px; font-weight: 600; }
.fix-tools button small { font-size: 10.5px; color: var(--muted); line-height: 1.2; }
.ic-keep { background: #ff3c3c99; }
.ic-erase { border: 2px dashed #ff6b6b; }
.ic-off { border: 2px dashed #ffffffaa; }
.ic-off::after, .ic-add::after { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 14px; line-height: 1; }
.ic-off::after { content: "−"; color: #fff; }
.ic-add { border: 2px solid #4fc3f7; }
.ic-add::after { content: "+"; color: #4fc3f7; }
.fix-hint { margin: 8px 0 4px; font-size: 12px; line-height: 1.4; padding: 6px 8px; border-radius: 6px; background: #ffb02014; border-left: 3px solid #ffb020; }
.fix-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--muted); margin: 4px 0; }
.fix-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.fix-legend i.ring { border: 2px solid; }
.fix-legend i.ring.dash { border: 2px dashed #ffffffaa; }
.fix-keys { font-size: 11px; color: var(--muted); }
.fix-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.fix-actions .link { margin-left: auto; }
.heal-ov { position: absolute; pointer-events: none; z-index: 3; }

.modal-wrap { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 30; }
.modal { width: min(440px, calc(100vw - 32px)); background: var(--bg3); border: 1px solid var(--line2); border-radius: 12px; padding: 18px; box-shadow: 0 20px 60px #000c; }
.modal h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.modal p { margin: 0 0 12px; color: #c9c6c0; line-height: 1.5; }
.modal-input { width: 100%; background: var(--bg); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; outline: none; margin-bottom: 14px; }
.modal-input:focus { border-color: var(--accent); }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-btns .btn.tall { flex: 1 1 100%; text-align: left; padding: 9px 12px; white-space: normal; }
.modal-btns .btn small { display: block; font-weight: 400; font-size: 11.5px; opacity: .75; margin-top: 2px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2e3036; border-radius: 9px; border: 2px solid var(--bg2); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1100px) { .layout { grid-template-columns: 240px 1fr 290px; } }

/* Phím tắt Chuẩn hóa (< > - = Enter) */
.sl.kbd { margin-left: -8px; margin-right: -8px; padding: 3px 8px 1px; border-radius: 6px; background: #f0a04a1c; box-shadow: inset 2px 0 0 var(--accent); }
.sl.kbd .sl-top span:first-child { color: var(--accent2); }
.key-hud { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 4; pointer-events: none; padding: 8px 16px; border-radius: 8px; background: #000b; color: #fff; font-size: 14px; white-space: nowrap; opacity: 0; transition: opacity .15s; }
.key-hud.on { opacity: 1; }
.key-hud b { color: var(--accent2); margin-left: 8px; font-variant-numeric: tabular-nums; }

/* Nắn dáng, Xóa vật thể */
.rt-tools { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; }
.rt-tools button { border: 1px solid var(--line2); background: transparent; color: #cfcbc4; border-radius: 6px; padding: 7px 4px; font: inherit; font-size: 12px; cursor: pointer; }
.rt-tools button:hover { background: #ffffff0d; }
.rt-tools button.on { background: #ffb02022; border-color: #ffb020; color: #fff; }
.rt-targets { flex-wrap: wrap; margin: 6px 0; }
.viewer.rt-on #cv { cursor: none; }
.viewer.rt-pick #cv { cursor: crosshair; }

/* Cài đặt xuất */
.modal.exp label { display: block; margin: 12px 0; font-size: 13px; }
.modal.exp label b { float: right; color: var(--accent2); }
.modal.exp select, .modal.exp input[type=range] { display: block; width: 100%; margin-top: 5px; }
.modal.exp select { padding: 7px 8px; background: #1b1d22; color: inherit; border: 1px solid #333842; border-radius: 6px; font: inherit; }
.modal.exp label.ck { display: flex; gap: 8px; align-items: flex-start; }
.modal.exp label[hidden] { display: none; }
@media (max-width: 1440px) { #btnExportOpt span, .brand small { display: none; } .actions .btn { padding-left: 9px; padding-right: 9px; white-space: nowrap; } }
