.graph-editor-dialog[open]:has(.dmate-drawing-workspace){display:flex;flex-direction:column;overflow:hidden}
.graph-editor-dialog:has(.dmate-drawing-workspace)>#graphEditorMount{flex:1;min-height:0}
.has-drawing-workspace{height:100%;min-height:0}
.graph-editor-dialog:has(.dmate-drawing-workspace),.dmate-drawing-workspace{--ddw-close-size:20px}
.dmate-drawing-workspace{height:100%;min-height:0;box-sizing:border-box;display:flex;flex-direction:column;gap:14px;padding-top:12px;color:var(--text-primary,#172033);position:relative}
.ddw-header{display:flex;align-items:center;gap:8px;flex-wrap:wrap;flex-shrink:0}
.ddw-name{width:190px;min-width:100px;max-width:100%;border:1px solid var(--border-strong,#cbd5e1);border-radius:9px;background:var(--surface-1,#fff);color:inherit;padding:9px 11px;font:inherit}
.ddw-page-actions{display:flex;flex-wrap:wrap;gap:6px;margin-left:auto;min-width:0;max-width:100%}
.ddw-page-actions>button{white-space:nowrap}
.graph-editor-dialog>.graph-editor-dialog-head.has-drawing-header-export{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:center}
.graph-editor-dialog>.graph-editor-dialog-head.has-drawing-header-export:has(>.graph-editor-close-dot){grid-template-columns:minmax(0,1fr) auto auto}
.graph-editor-dialog-head>.ddw-header-export{flex:0 0 auto}
.ddw-header>.ddw-header-export{flex:0 0 auto}
.dmate-drawing-workspace button{font:inherit;color:inherit;background:var(--surface-2,#f8fafc);border:1px solid var(--border-strong,#cbd5e1);border-radius:9px;padding:9px 12px;cursor:pointer;touch-action:manipulation}
.dmate-drawing-workspace button:hover:not(:disabled){filter:none}
/* Keep the existing button dimensions while removing the visible frame. */
.dmate-drawing-workspace :is(.ddw-page-actions>button:not(.ddw-upload-button),.ddw-editor>.dge-topline>button,.ddw-editor .dge-view-controls>button){--dm-control-bg:transparent;--dm-control-border:transparent;--dm-control-hover-bg:var(--dm-nav-hover,var(--dm-selected-hover,var(--surface-2)));--dm-control-hover-border:transparent;background-color:transparent!important;border-color:transparent!important;box-shadow:none!important}
@media(hover:hover){.dmate-drawing-workspace :is(.ddw-page-actions>button:not(.ddw-upload-button),.ddw-editor>.dge-topline>button,.ddw-editor .dge-view-controls>button):hover:not(:disabled){background-color:var(--dm-nav-hover,var(--dm-selected-hover,var(--surface-2)))!important;border-color:transparent!important}}
/* Disabled controls keep the same outline; only their text and icons fade. */
.dmate-drawing-workspace button:disabled{opacity:1;color:color-mix(in srgb,var(--text-primary,#172033) 55%,transparent);cursor:wait}
.dmate-drawing-workspace button:focus,.dmate-drawing-workspace summary:focus,.ddw-name:focus,.ddw-ai-requirement:focus{outline:none!important;box-shadow:none!important}
.dmate-drawing-workspace .ddw-primary{background:var(--accent,#3b82f6);border-color:var(--accent,#3b82f6);color:white}
.dmate-drawing-workspace .ddw-primary:disabled{color:color-mix(in srgb,#fff 55%,transparent)}
.dmate-drawing-workspace .ddw-upload-button{min-width:64px}
.dmate-drawing-workspace .ddw-guide-button{display:flex;align-items:center;justify-content:center;position:relative;box-sizing:border-box;width:38px;min-width:38px;max-width:38px;height:38px;min-height:38px;max-height:38px;margin:0;padding:0;border:0;border-radius:50%;font-size:0;background:var(--accent,#3b82f6);color:#fff;box-shadow:none;transition:var(--dm-control-transition,background-color .12s ease,color .12s ease)}
.dmate-drawing-workspace .ddw-guide-button:disabled{background:var(--border-strong,#737373);color:var(--text-subtle,#9ca3af);cursor:not-allowed}
.dmate-drawing-workspace .ddw-guide-button>svg{display:block;flex:0 0 18px;width:18px;max-width:18px;height:18px;max-height:18px;pointer-events:none}
.ddw-body{flex:1;min-height:0;position:relative;display:flex;overflow:hidden}
.ddw-editor{flex:1;min-width:0;min-height:0;overflow:hidden}
.ddw-editor.dmate-graph-editor{height:100%;display:flex;flex-direction:column}
.ddw-editor>.dge-topline{flex-wrap:nowrap;min-width:0}
.ddw-editor>.dge-topline>.dge-clear-button{display:inline-flex;align-items:center;justify-content:center;gap:6px}
.ddw-editor>.dge-topline>.dge-clear-button>svg{display:block;flex:none;width:20px;height:20px;pointer-events:none}
.ddw-editor>.dge-workspace{flex:1;min-height:0}
.ddw-editor .dge-workspace .dge-selection-panel{top:auto;bottom:var(--ddw-property-bottom,12px);max-height:max(0px,calc(100% - var(--ddw-property-top,120px) - var(--ddw-property-bottom,12px)));min-height:0}
.ddw-editor .dge-selection-panel .dge-field{flex:0 0 auto}
.ddw-editor .dge-overlay-host{height:100%;min-height:0;border:0}
.ddw-editor .dge-overlay{height:100%;min-height:0;max-height:none;display:flex;flex-direction:column;gap:8px}
/* Canvas navigation shares the action row, after Undo/Redo/Clear. */
.ddw-editor .dge-view-controls{flex:0 0 auto;flex-wrap:nowrap;margin-left:auto;padding:0;border:0;border-radius:0;background:transparent;box-shadow:none}
/* A single rounded frame clips the complete scrolling canvas. Native scroll
   remains available for wheel/touch/pan without reserving white track gutters. */
.ddw-canvas-frame{display:flex;flex:1;min-width:0;min-height:0;overflow:hidden;border:1px solid var(--dge-border,#cbd5e1);border-radius:12px}
.ddw-editor .dge-overlay-viewport{height:auto;flex:1;min-width:0;min-height:0;max-height:none;border:0;border-radius:11px;scrollbar-gutter:auto;scrollbar-width:none}
.ddw-editor .dge-overlay-viewport::-webkit-scrollbar{display:none;width:0;height:0}
.ddw-side-actions{position:absolute;z-index:16;right:var(--ddw-controls-right,18px);top:var(--ddw-controls-top,76px);display:flex;gap:6px;flex-direction:row;flex-wrap:wrap;justify-content:flex-end;width:max-content;max-width:calc(100% - 36px)}
.ddw-side-actions[hidden]{display:none}
.ddw-side-actions>button{flex-shrink:0;min-width:0;padding:8px 10px;white-space:nowrap;font-size:13px;box-shadow:0 3px 12px #0000000f;background:var(--surface-1,#fff)}
.ddw-editor .dge-floating-actions{right:10px;top:var(--ddw-panel-top,120px);display:block;width:min(380px,calc(100% - 20px));height:0;z-index:14}
.ddw-editor .dge-floating-actions>.dge-float-panel{border:0;box-shadow:none;background:transparent}
.ddw-editor .dge-floating-actions>.dge-float-panel>summary{display:none!important}
/* Native details can retain a hidden paint/hit-test cache for fixed children.
   Explicit visibility keeps repeated toggles responsive without changing state. */
.ddw-editor :is(.dge-tool-palette,.dge-float-panel)::details-content{content-visibility:visible!important}
.ddw-editor .dge-tool-palette:not([open])>.dge-overlay-tools,.ddw-editor .dge-float-panel:not([open])>.dge-float-content{display:none!important}
.ddw-editor .dge-float-content{position:fixed;visibility:hidden;width:min(380px,calc(100vw - 16px));z-index:20}
.ddw-side-panel{position:fixed;visibility:hidden;z-index:20;width:min(380px,calc(100vw - 16px))}
.ddw-side-panel,.ddw-editor .dge-float-content,.ddw-editor .dge-tool-palette>.dge-overlay-tools{max-height:var(--ddw-panel-space,50dvh);overflow:auto;overscroll-behavior:contain;padding:12px;box-sizing:border-box;border:1px solid var(--border-strong,#cbd5e1);border-radius:12px;background:var(--surface-1,#fff);box-shadow:0 6px 22px #0002}
.ddw-editor .dge-tool-palette{left:var(--ddw-tools-left,18px)!important;top:var(--ddw-tools-top,76px)!important;width:max-content;max-width:calc(100% - 20px);margin:0;padding:0;border:0;border-radius:0;background:transparent;box-shadow:none;z-index:15}
.ddw-editor .dge-tool-palette>summary,.ddw-editor .dge-tool-palette[open]>summary{padding:8px 10px;margin:0;border:1px solid var(--border-strong,#cbd5e1);border-radius:9px;background:var(--surface-1,#fff);color:inherit;font-size:13px;font-weight:400;line-height:1.4;box-shadow:0 3px 12px #0000000f}
.ddw-editor .dge-tool-palette>.dge-overlay-tools{position:fixed;visibility:hidden;width:160px;gap:8px;flex-wrap:nowrap;z-index:20}
.ddw-editor .dge-tool-palette>summary[aria-disabled=true]{opacity:1;color:color-mix(in srgb,var(--text-primary,#172033) 55%,transparent);cursor:default}
.ddw-side-actions>button:disabled{cursor:default}
.ddw-editor .dge-tool-palette .dge-overlay-status:empty{display:none}
.ddw-editor .dge-float-panel .dge-toolbar{padding:0;gap:12px;border:0;border-radius:0;background:transparent;align-items:stretch}
.ddw-editor .dge-float-panel .dge-review-summary{background:transparent;padding:0}
.ddw-editor .dge-float-panel .dge-review-summary>h3{display:none}
.ddw-editor .dge-float-panel .dge-review-content{padding:0}
.ddw-side-panel[hidden]{display:none}
.ddw-panel-header,.ddw-editor-panel-header{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-bottom:12px}
/* Drawing panel titles use the same body-font tokens as ordinary modal heads. */
.dmate-drawing-workspace :is(.ddw-panel-header>h3,.ddw-editor-panel-header>h3,.ddw-export-header>h3,.dge-property-head>h3),
.graph-editor-dialog:has(.dmate-drawing-workspace) .dmate-delete-confirm .dmate-delete-confirm-title{margin:0;font-family:var(--dmate-font-ui);font-size:var(--font-base,16px);font-weight:400;line-height:inherit}
.ddw-history-empty{font-size:14px;color:var(--text-secondary,#64748b);margin:0;text-align:center}
.ddw-history-list{display:grid;gap:8px}
.ddw-history-item{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:8px;padding:8px;border:1px solid var(--border-strong,#cbd5e1);border-radius:10px}
.ddw-history-item.is-current{background:var(--surface-2,#f8fafc)}
.ddw-history-open{border:0!important;padding:2px!important;text-align:left;background:transparent!important;overflow-wrap:anywhere;font-weight:600!important}
.dmate-drawing-workspace .ddw-history-delete{position:relative;grid-column:2;align-self:center}
.dmate-drawing-workspace :is(.ddw-history-delete,.ddw-export-close,.dge-panel-close),
.graph-editor-dialog:has(.dmate-drawing-workspace) .dmate-delete-confirm-close{display:block;box-sizing:border-box;flex:0 0 var(--ddw-close-size);appearance:none;-webkit-appearance:none;width:var(--ddw-close-size);min-width:var(--ddw-close-size);max-width:var(--ddw-close-size);height:var(--ddw-close-size);min-height:var(--ddw-close-size);max-height:var(--ddw-close-size);margin:0;padding:0;border:0;border-radius:50%;background:#ef4444;color:transparent;font-size:0;line-height:0;cursor:pointer;box-shadow:none}
.ddw-history-delete::before{content:'';position:absolute;inset:-6px;border-radius:50%}
.ddw-ai-label{display:flex;flex-direction:column;gap:7px;font-size:14px;margin-bottom:10px}
.ddw-ai-actions{display:flex;align-items:center;flex-wrap:wrap;gap:9px;margin-top:2px}
.ddw-ai-requirement{width:100%;box-sizing:border-box;resize:vertical;min-height:70px;max-height:200px;padding:9px;border-radius:8px;border:1px solid var(--border-strong,#cbd5e1);background:var(--surface-2,#f8fafc);color:inherit;font:inherit}
.ddw-ai-answer{font-size:14px;white-space:normal;overflow-wrap:anywhere;line-height:1.7;margin-top:14px}
.ddw-ai-answer:empty{display:none}
.ddw-export-preview{position:absolute;inset:0;z-index:30;box-sizing:border-box;display:flex;align-items:center;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--border-strong,#cbd5e1);border-radius:12px;background:var(--surface-1,#fff);overflow:auto}
.ddw-export-header{display:flex;width:100%;align-items:center;justify-content:space-between;gap:12px;flex-shrink:0}
.ddw-export-image{display:block;max-width:100%;width:auto;height:auto;max-height:calc(100% - 120px);min-height:0;object-fit:contain;background:white;user-select:auto;-webkit-user-select:auto;-webkit-touch-callout:default}
.ddw-export-download{display:inline-block;border-radius:9px;padding:10px 20px;background:var(--accent,#3b82f6);color:white;text-decoration:none;flex-shrink:0}
@media(max-width:760px){.graph-editor-dialog:has(.dmate-drawing-workspace),.dmate-drawing-workspace{--ddw-close-size:22px}}
@media(max-width:600px){.ddw-header{gap:6px}.ddw-name{width:100%;padding:7px 10px}.ddw-page-actions{width:100%;margin:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}.ddw-page-actions>button{font-size:12px;padding:8px 10px;white-space:nowrap}.ddw-side-actions{gap:4px}.ddw-side-actions>button{font-size:12px;padding:7px 6px}.ddw-editor .dge-tool-palette>summary,.ddw-editor .dge-tool-palette[open]>summary{padding:7px 8px;font-size:12px}}
@media(max-width:600px){.ddw-editor>.dge-topline{gap:4px}.ddw-editor>.dge-topline>.dge-clear-button{font-size:14px;padding:6px 8px}.ddw-editor .dge-view-controls{gap:2px}.ddw-editor .dge-view-controls>button{padding:5px 6px}}
@media(max-width:900px){
 .ddw-side-panel,.ddw-editor .dge-float-content{width:min(300px,calc(100vw - 24px));padding:10px}
 .ddw-panel-header,.ddw-editor-panel-header{gap:8px;margin-bottom:8px}
 .ddw-editor .dge-float-panel .dge-toolbar{gap:8px}
 .ddw-editor .dge-tool-palette>.dge-overlay-tools{width:156px;padding:8px;gap:6px}
 .ddw-editor .dge-tool-palette .dge-overlay-tools button{min-height:36px}
 .ddw-editor .dge-workspace .dge-selection-panel{right:12px;width:min(300px,calc(100% - 24px));--dge-property-padding:10px;--dge-property-gap:8px}
 .ddw-editor .dge-property-body{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-content:start}
 .ddw-editor .dge-property-body>*{grid-column:1/-1}
 .ddw-editor .dge-property-body>.dge-endpoint-field{grid-column:auto}
 .ddw-editor .dge-selection-panel .dge-field{gap:4px}
 .ddw-editor :is(.dge-selection-panel,.dge-float-content) :is(input:not([type=checkbox]):not([type=radio]),select){font-size:16px;min-height:40px;padding:6px 8px;box-sizing:border-box}
 .ddw-editor .dge-selection-panel .dge-danger{min-height:36px}
 .ddw-ai-label{gap:6px;margin-bottom:8px}
 .ddw-ai-requirement{font-size:16px;line-height:1.4;min-height:60px;max-height:160px;padding:7px 8px}
 .ddw-history-list{gap:6px}
 .ddw-history-item{gap:6px;padding:6px}
}
