.canvas-dialog,.asset-dialog{color-scheme:dark;color:var(--ink);background:#11191c;border:1px solid var(--line);padding:0;border-radius:9px;box-shadow:0 18px 90px #000a}
.canvas-dialog::backdrop,.asset-dialog::backdrop{background:#000b}
.canvas-dialog{width:calc(100vw - 24px);height:calc(100dvh - 24px);max-width:2100px;max-height:none;overflow:hidden}
.canvas-dialog[open]{display:flex;flex-direction:column}
.editor-heading{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 18px;border-bottom:1px solid var(--line);flex-shrink:0}
.editor-heading h2{font-size:18px;line-height:1.3;font-weight:550;margin:0;letter-spacing:0}
#editor-changes{font-size:11px;color:#cedabc}
.editor-bar{display:flex;flex-wrap:wrap;gap:6px;padding:8px 16px;border-bottom:1px solid var(--line);align-items:center;flex-shrink:0}
.editor-bar button,.layer-actions button{font-size:12px;min-height:36px;padding:6px 10px}
.editor-bg{display:flex;align-items:center;gap:8px;font-size:12px;margin-left:auto}
.editor-bg input[type=color]{width:42px;padding:3px;min-height:32px;height:32px}
.editor-bar .check{margin:0;font-size:12px}
.editor-workspace{display:grid;grid-template-columns:190px minmax(0,1fr) 248px;min-height:0;flex:1;overflow:hidden}
.editor-layers,.editor-properties{overflow:auto;padding:12px;background:#152024;scrollbar-gutter:stable}
.editor-layers{border-right:1px solid var(--line)}
.editor-layers h3{font-size:13px;font-weight:550;margin:0 0 12px}
.editor-properties{border-left:1px solid var(--line)}
.editor-properties input,.editor-properties select,.editor-properties textarea{font-size:12px;padding:6px!important;min-height:32px!important}
.editor-properties textarea{min-height:100px!important}
.editor-properties label{font-size:12px;color:var(--muted)}
.editor-properties .field{margin-bottom:12px}
.editor-properties input[type=range]{min-height:22px!important}
.editor-properties input[type=color]{height:32px}
.property-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin-bottom:12px}
.property-grid>label{display:flex;flex-direction:column;gap:4px;min-width:0}
.property-grid input{min-width:0}
.editor-center{padding:24px;display:flex;flex-direction:column;justify-content:center;min-width:0;min-height:0;background:#0b1113;overflow:auto}
#canvas-host{width:100%;flex:0 0 auto;box-shadow:0 0 0 1px #354b54,0 8px 25px #0005;touch-action:none;user-select:none;outline-offset:6px}
#canvas-host .native-element{cursor:move}
#canvas-host .layer-locked{cursor:pointer}
#canvas-host .native-element img,#canvas-host .native-element video{pointer-events:none}
#canvas-host .native-text{user-select:none}
#editor-status{font-size:12px;margin:12px 0 0;min-height:36px;color:var(--muted)}
.layer-selection{position:absolute;border:2px solid #c8edb9;pointer-events:none;box-sizing:border-box;transform-origin:center;z-index:999}
.resize-handle{position:absolute;background:#c8edb9;border:1px solid #102018;pointer-events:auto;transform:translate(-50%,-50%)}
.resize-handle.nw{left:0;top:0;cursor:nwse-resize}.resize-handle.ne{left:100%;top:0;cursor:nesw-resize}.resize-handle.sw{left:0;top:100%;cursor:nesw-resize}.resize-handle.se{left:100%;top:100%;cursor:nwse-resize}
.layer-row{width:100%;text-align:left;justify-content:flex-start;min-height:32px;padding:7px 8px;font-size:12px;border:0;background:transparent;margin-bottom:3px;overflow:hidden;overflow-wrap:anywhere}
.layer-row.selected{background:#29413b;color:var(--accent)}
.layer-actions{display:grid;grid-template-columns:1fr 1fr;gap:5px;padding:12px 0;border-top:1px solid var(--line)}
#blank-layout,#load-original{font-size:12px;width:100%;margin-top:9px}
.editor-saving .editor-workspace,.editor-saving .editor-bar{pointer-events:none;opacity:.7}
.asset-dialog{width:min(1160px,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:auto}
.asset-dialog .editor-heading{position:sticky;top:0;background:#11191c;z-index:2}
.library-tools{display:flex;gap:16px;padding:16px;align-items:end;flex-wrap:wrap}
.library-tools label{font-size:12px}
.library-tools label:first-child{flex:1;min-width:160px}
.library-grid{padding:8px 16px 20px;display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:16px}
.library-card{background:#1b282d;padding:10px;border:1px solid #30454c;border-radius:8px;min-width:0}
.library-card>img,.library-card>video{width:100%;height:145px;object-fit:contain;background:#0d1417;border-radius:3px}
.library-card>audio{width:100%;height:60px;margin:35px 0 50px}
.library-card label{display:block;font-size:11px;margin:8px 0}
.library-card input{font-size:12px;padding:6px!important;min-height:32px!important}
.library-card button,.library-card .quiet{font-size:12px;padding:6px 9px}
#library-status{font-size:13px;margin:0 16px 10px;min-height:20px}
.admin-preview{position:relative;min-height:0}
#admin-native-preview{position:absolute;inset:0}
#edit-layout{flex:1}
@media(min-width:1100px){.admin-shell{max-width:1900px;padding-left:3%;padding-right:3%}.admin-grid{grid-template-columns:180px minmax(400px,1fr) 320px}}
@media(max-width:1100px){.editor-workspace{grid-template-columns:155px minmax(0,1fr) 210px}.editor-center{padding:14px}.editor-bar{padding:6px 10px}.editor-heading{padding:10px 12px}}
@media(max-width:760px){.canvas-dialog{width:100%;height:100dvh;border-radius:0;border:0;max-width:none;max-height:none;margin:0}.editor-heading h2{font-size:15px}.editor-heading button{font-size:12px;padding:8px;min-height:40px}.editor-workspace{display:flex;flex-direction:column;overflow:auto}.editor-center{order:0;flex-shrink:0;overflow:visible;padding:18px 14px 8px;min-height:180px}.editor-layers{order:2;flex-shrink:0;overflow:visible;border:0;border-top:1px solid var(--line)}.editor-properties{order:1;flex-shrink:0;border:0;border-top:1px solid var(--line);overflow:visible}.editor-properties #layer-properties{display:grid;grid-template-columns:1fr 1fr;gap:8px}.editor-properties #layer-properties>div[data-types]{grid-column:1/-1}.editor-properties #layer-properties>.field:first-child{grid-column:1/-1}.editor-bg{margin-left:0}.editor-bar{gap:5px}.editor-bar button{min-height:38px}#layer-list{display:flex;max-height:150px;overflow:auto;gap:4px;flex-wrap:wrap}.layer-row{width:auto;max-width:180px}.layer-actions{grid-template-columns:repeat(3,1fr)}.asset-dialog{width:calc(100vw - 12px);max-height:calc(100dvh - 12px)}.library-grid{grid-template-columns:repeat(2,minmax(0,1fr));padding:10px;gap:10px}.library-card>img,.library-card>video{height:110px}.library-tools{padding:12px;gap:10px}.library-tools .button{min-height:40px;font-size:12px}.editor-heading>.row{flex-wrap:nowrap}}
@media(max-height:500px) and (orientation:landscape){.canvas-dialog .editor-heading{padding:4px 12px}.canvas-dialog .editor-bar{padding:4px}.editor-workspace{display:grid;grid-template-columns:140px minmax(0,1fr) 200px;overflow:hidden}.editor-center,.editor-layers,.editor-properties{order:0;overflow:auto;min-height:0}.editor-properties #layer-properties{display:block}.editor-center{padding:12px}#editor-status{display:none}.editor-heading button{min-height:34px}}

/* Keep tool controls usable in narrow sidebars. */
.layer-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
.layer-actions button{min-width:0;padding:7px 3px;font-size:11px;overflow-wrap:anywhere}
.canvas-dialog .editor-bg input[type=color]{width:42px;min-width:42px;padding:2px!important;min-height:32px}
.canvas-dialog .editor-properties input[type=color]{padding:2px!important}
@media(max-width:760px) and (orientation:portrait){.layer-actions{grid-template-columns:repeat(3,minmax(0,1fr))}}

body.editor-modal-open{position:fixed;inset:0;width:100%;overflow:hidden}
.canvas-dialog{overscroll-behavior:contain}
.editor-workspace,.editor-layers,.editor-properties,.editor-center{overscroll-behavior:contain;scrollbar-gutter:stable}
.editor-layers,.editor-properties{touch-action:pan-y;min-height:0}
.editor-center{touch-action:pan-y}
@media(max-width:760px){.editor-workspace{touch-action:pan-y}.editor-center,.editor-layers,.editor-properties{max-height:none}}
[data-theme="light"] .canvas-dialog,[data-theme="light"] .asset-dialog{color-scheme:light;background:#ffffff;color:var(--ink);box-shadow:0 18px 90px #17313b33}
[data-theme="light"] .editor-layers,[data-theme="light"] .editor-properties{background:#f3f6f4}
[data-theme="light"] .editor-center{background:#e8eeec}
[data-theme="light"] .asset-dialog .editor-heading{background:#ffffff}
[data-theme="light"] .library-card{background:#f5f7f6;border-color:#c8d1ce}
[data-theme="light"] .library-card>img,[data-theme="light"] .library-card>video{background:#e6ebea}
[data-theme="light"] .layer-row.selected{background:#d9ebe3;color:#174f3b}
