/* Shared unit constructor. Scoped to keep the existing pages unchanged. */
.unit-reveal .ctor-actions{display:flex;gap:8px;flex-shrink:0;}
.unit-reveal .ctor-actions>.btn{flex:1 1 0;min-width:0;width:0;padding:10px 6px;white-space:normal;text-align:center;}
.ctor-dialog{box-sizing:border-box;position:fixed;inset:0;margin:auto;width:calc(100vw - 40px);max-width:1800px;height:calc(100dvh - 40px);max-height:none;padding:0;border:1px solid var(--border-strong,#3a4d66);border-radius:8px;background:var(--surface,#152640);color:var(--text,#edf2f7);box-shadow:0 24px 100px #0009;overflow:hidden;}
.ctor-dialog::backdrop{background:#050d18d9;backdrop-filter:blur(5px);}
.ctor-shell{height:100%;display:flex;flex-direction:column;min-height:0;}
.ctor-header{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px 20px;border-bottom:1px solid var(--border-strong,#3a4d66);}
.ctor-header h2{font-size:20px;line-height:1.3;margin:0;}
.ctor-size{margin:4px 0 0;color:var(--text-muted,#bac5d4);font-size:14px;}
.ctor-dialog button{font:inherit;cursor:pointer;border-radius:8px;}
.ctor-dialog button:focus-visible,.ctor-canvas:focus-visible{outline:2px solid var(--accent,#e2632c);outline-offset:3px;}
.ctor-close{flex:0 0 44px;width:44px;height:44px;border:1px solid var(--border-strong,#3a4d66);background:var(--surface-2,#1c3050);color:inherit;font-size:26px!important;}
.ctor-body{display:flex;flex:1;min-height:0;}
.ctor-stage{flex:1;display:flex;flex-direction:column;min-width:0;min-height:0;}
.ctor-toolbar{display:flex;flex-wrap:wrap;gap:8px;padding:12px;}
.ctor-toolbar button{min-height:44px;padding:8px 12px;border:1px solid var(--border-strong,#3a4d66);background:var(--surface-2,#1c3050);color:inherit;font-size:13px;}
.ctor-dialog button:hover{border-color:var(--accent,#e2632c);}
.ctor-dialog button:disabled{opacity:.4;cursor:default;}
.ctor-viewport{position:relative;flex:1;min-height:140px;background:radial-gradient(ellipse at 50% 40%,#4b5057 0%,#262a30 55%,#14171b 100%);overflow:hidden;}
.ctor-canvas{display:block;width:100%;height:100%;touch-action:none;}
.ctor-hint{margin:0;padding:10px 14px;color:var(--text-muted,#bac5d4);font-size:12px;line-height:1.5;}
.ctor-status{min-height:1.5em;margin:0;padding:0 14px 8px;font-size:13px;color:#ffb48e;}
.ctor-palette{box-sizing:border-box;display:flex;flex-direction:column;flex:0 0 min(340px,34%);min-width:0;min-height:0;overflow:hidden;padding:12px 16px;border-left:1px solid var(--border-strong,#3a4d66);}
.ctor-palette h3{margin:0 0 8px;font-size:14px;}
.ctor-items{display:grid;flex:1;min-height:0;grid-template-columns:repeat(5,var(--ctor-tile-size,44px));grid-auto-rows:var(--ctor-tile-size,44px);gap:8px;align-content:start;justify-content:center;}
.ctor-empty-slot{aspect-ratio:1;border:1px solid #3a4d6655;border-radius:8px;background:#07132155;}
.ctor-item{position:relative;display:grid;place-items:center;aspect-ratio:1;min-width:0;min-height:0;padding:3px;border:1px solid var(--border-strong,#3a4d66);background:var(--surface-2,#1c3050);color:inherit;touch-action:none;user-select:none;}
.ctor-swatch{display:block;width:60%;height:60%;border-radius:8px;background-size:contain;background-position:center;background-repeat:no-repeat;pointer-events:none;}
.ctor-swatch.ctor-thumbnail{width:100%;height:100%;background-color:transparent!important;}
.ctor-count{position:absolute;right:4px;top:4px;padding:1px 5px;border-radius:8px;background:var(--accent,#e2632c);color:#fff;font-size:12px;line-height:1.4;pointer-events:none;}
.ctor-count[hidden]{display:none;}
.ctor-tooltip{position:absolute;left:0;right:0;bottom:0;padding:4px 3px;border-radius:0 0 8px 8px;background:#071321ee;color:#fff;font-size:11px;line-height:1.3;opacity:0;pointer-events:none;overflow-wrap:anywhere;z-index:1;}
.ctor-item:hover .ctor-tooltip,.ctor-item:focus-visible .ctor-tooltip{opacity:1;}
.ctor-drag-ghost{position:fixed;z-index:5;display:grid;place-items:center;box-sizing:border-box;width:72px;height:72px;pointer-events:none;transform:translate(-50%,-115%);padding:4px;border:1px solid var(--accent,#e2632c);border-radius:8px;background:#152640ed;}
.ctor-footer{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 20px;border-top:1px solid var(--border-strong,#3a4d66);}
.ctor-meters{font-size:13px;line-height:1.7;}
.ctor-meter-label{color:var(--text-muted,#bac5d4);}
.ctor-meter-value{font-weight:600;font-variant-numeric:tabular-nums;}
.ctor-footer .btn{min-height:44px;white-space:normal;text-align:center;}
.ctor-error{padding:24px;line-height:1.6;}
@media(max-width:800px){
 .ctor-dialog{width:100%;max-width:100%;height:100dvh;max-height:100dvh;margin:0;border:0;border-radius:0;}
 .ctor-header{padding:12px 14px;padding-top:max(12px,env(safe-area-inset-top));}
 .ctor-header h2{font-size:18px;}
 .ctor-body{display:flex;flex-direction:column;overflow-y:auto;}
 .ctor-stage{flex:1 0 auto;min-height:0;}
 .ctor-viewport{flex:1 0 45dvh;min-height:45dvh;}
 .ctor-toolbar{flex-wrap:nowrap;overflow-x:auto;gap:6px;padding:8px;}
 .ctor-toolbar button{flex-shrink:0;padding:7px 9px;font-size:12px;}
 .ctor-palette{display:block;flex:0 1 auto;max-height:24dvh;min-height:95px;overflow-y:auto;padding:8px 10px;border-left:0;border-top:1px solid var(--border-strong,#3a4d66);}
 .ctor-palette h3{font-size:12px;margin-bottom:7px;}
 .ctor-items{grid-template-columns:repeat(6,minmax(0,46px));grid-auto-rows:auto;gap:8px;justify-content:center;}
 .ctor-empty-slot{display:none;}
 .ctor-item{min-height:44px;}
 .ctor-footer{gap:10px;padding:10px 14px;padding-bottom:max(10px,env(safe-area-inset-bottom));}
 .ctor-footer .btn{padding:10px 12px;max-width:145px;font-size:13px;}
 .ctor-meters{font-size:11px;}
 .ctor-hint{padding:6px 12px;font-size:11px;}
 .ctor-status{font-size:12px;padding-bottom:5px;}
}

@media(max-width:800px) and (max-height:600px){
 .ctor-stage{min-height:0;}
 .ctor-palette{max-height:22dvh;min-height:70px;}
}
