.template-workspace{grid-template-columns:minmax(180px,235px) minmax(0,1fr);gap:12px}.template-tree.panel{padding:12px;position:sticky;top:12px;max-height:calc(100vh - 90px)}.template-tree h2{margin:0 0 8px}.template-tree .hint{font-size:.8rem;margin:6px 0}.template-breadcrumb{font-size:.82rem;margin:6px 0}.template-group{border:0;padding:2px 0}.template-group>summary,.template-function>summary{padding:5px 0;font-size:.85rem;line-height:1.2}.template-function{margin-left:10px;border-left:1px solid var(--line);padding-left:8px}.template-count{color:var(--muted);font-weight:400;font-size:.85em;margin-left:4px}.template-tree .template-file{display:flex;gap:5px;align-items:center;margin:1px 0;padding:4px 5px;border-radius:4px;font:12px/1.35 Consolas,monospace}.template-file>span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.template-file>span:first-child{color:var(--muted)}.template-editor{overflow:hidden}.template-editor>h2{font-size:1rem;margin-bottom:6px}.template-editor>p{margin:6px 0}.template-editor>label{max-width:450px}.template-split{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:12px}.template-split>section{min-width:0}.template-pane-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:32px;margin-bottom:8px}.template-pane-heading h3{font-size:.95rem;margin:0}.template-pane-heading .hint{font-size:.74rem;max-width:240px}.template-source-label{display:flex;flex-direction:column;height:100%;margin:0}.template-editor .template-source{width:100%;min-height:480px;height:65vh;resize:vertical;border:1px solid var(--line);font:13px/1.5 Consolas,monospace;tab-size:4;padding:10px}.template-preview-controls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.template-preview-pane label{font-size:.8rem;margin:0 0 8px;min-width:0;display:block}.template-preview-pane select{width:100%;min-width:0}.template-preview-pane .template-preview{height:calc(65vh - 122px);min-height:350px;overflow:auto;margin:8px 0 0;white-space:pre;font:13px/1.5 Consolas,monospace;border:1px solid var(--line);padding:10px}.template-preview-pane[aria-busy=true]{opacity:.55}.template-policy-help{font-size:.85rem}.template-policy-help ol{padding-left:22px}.template-policy-help li{margin:7px 0}.template-policy-help .button{margin:4px}.template-editor .connection-actions{margin-top:12px}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
@media(max-width:1100px){.template-workspace{grid-template-columns:190px minmax(0,1fr)}.template-split{grid-template-columns:1fr}.template-tree.panel{max-height:80vh}.template-editor .template-source{height:50vh}.template-preview-pane .template-preview{height:50vh}}
@media(max-width:700px){.template-workspace{grid-template-columns:1fr}.template-tree.panel{position:static;max-height:260px}.template-preview-controls{grid-template-columns:1fr}.template-editor .template-source{min-height:300px}.template-pane-heading{align-items:flex-start}}

.template-tree.panel{width:100%;max-width:100%;box-sizing:border-box}.template-tree .template-file{max-width:100%;min-width:0;box-sizing:border-box}.template-function{min-width:0}.template-tree input[type=search]{width:100%;margin:6px 0;font-size:.8rem}.template-policy-files{max-height:180px;overflow:auto;padding-left:20px}

.template-tree [hidden]{display:none!important}

.template-draft-actions{display:flex;gap:16px;flex-wrap:wrap;margin:8px 0}.template-draft-actions .link{font-size:.8rem}

@media(min-width:701px) and (max-width:1100px){.template-workspace{grid-template-columns:1fr}.template-tree.panel{position:static;max-height:200px}.template-split{grid-template-columns:repeat(2,minmax(0,1fr))}.template-editor .template-source{height:55vh;min-height:350px}.template-preview-pane .template-preview{height:calc(55vh - 122px);min-height:250px}}
/* Keep selection controls visible while the compact file tree scrolls independently. */
.template-tree.panel{display:flex;flex-direction:column;overflow:hidden;max-height:calc(100vh - 30px)}
.template-combination .template-target-grid{display:grid;grid-template-columns:1fr;gap:7px}
.template-combination label{font-size:.78rem;margin:0;min-width:0}
.template-combination select{width:100%;min-width:0}
.template-tree-files{overflow:auto;min-height:120px;flex:1;overscroll-behavior:contain;overflow-anchor:none}
.template-source-editor{position:relative;display:block;overflow:hidden;border-radius:8px}
.template-editor .template-source-highlight,.template-editor .template-source{box-sizing:border-box;margin:0;font:13px/1.5 Consolas,monospace;letter-spacing:normal;tab-size:4;padding:10px;white-space:pre;border:1px solid var(--line)}
.template-editor .template-source-highlight{position:absolute;inset:0;overflow:hidden;pointer-events:none;color:inherit;background:var(--white);border-radius:8px}
.template-source-highlight mark{background:#ffe680;color:#242000;border-radius:2px}
.template-editor .highlight-ready .template-source{position:relative;display:block;color:#202124;caret-color:#202124;background:transparent;resize:vertical;-webkit-text-fill-color:currentColor}
.template-editor .template-source::selection{background:rgba(100,150,230,.3)}
.template-draft-actions .button{font-size:.8rem}
@media(max-width:1100px){.template-workspace{grid-template-columns:220px minmax(0,1fr)}.template-tree.panel{position:sticky;max-height:calc(100vh - 30px)}.template-split{grid-template-columns:1fr}}
@media(max-width:700px){.template-workspace{grid-template-columns:1fr}.template-tree.panel{position:static;max-height:540px}.template-tree-files{max-height:180px}}

.template-combination{padding:0!important;margin:0 0 6px!important;border:0!important;background:transparent!important;box-shadow:none!important}
.template-combination .template-target-grid{padding:0;margin:0}
.template-source-editor:not(.highlight-ready) .template-source-highlight{display:none}
.template-tree-files{min-width:0;width:100%;max-width:100%;box-sizing:border-box;align-self:stretch;overflow-x:hidden}
.template-combination{align-self:stretch;min-width:0;width:100%}
.template-tree .template-group{min-width:0;max-width:100%}
/* Dense editor: labels stay beside their controls; short templates do not reserve empty rows. */
.template-edit-page .app-topbar{padding:6px 12px;min-height:42px;gap:8px}
.template-edit-page .app-topbar .appearance-controls{display:flex;align-items:center;gap:4px;flex-wrap:wrap}
.template-edit-page .app-topbar .appearance-controls select{max-width:135px}
.template-edit-page .app-content{padding:8px 12px}
.template-edit-page .template-page-heading{display:flex;justify-content:flex-start;align-items:center;gap:14px;margin:0 0 6px;padding:0}
.template-edit-page .template-page-heading h1{font-size:1rem;margin:0;line-height:1.3}
.template-edit-page .template-page-heading a{font-size:.8rem}
.template-edit-page .template-workspace{grid-template-columns:270px minmax(0,1fr);gap:8px}
.template-edit-page .template-workspace>.panel{padding:8px;border-radius:8px;margin:0}
.template-edit-page .template-tree h2,.template-edit-page .template-editor>h2{font-size:.92rem;margin:0 0 4px}
.template-edit-page .template-editor>p{font-size:.76rem;margin:2px 0 5px}
.template-edit-page .template-combination .template-target-grid{gap:3px}
.template-edit-page .template-combination label,.template-edit-page .template-editor>label,.template-edit-page .template-preview-pane label{display:grid;grid-template-columns:128px minmax(0,1fr);align-items:center;gap:5px;max-width:none;margin:0 0 3px;font-size:.76rem;line-height:1.2}
.template-edit-page .template-preview-pane label{grid-template-columns:110px minmax(0,1fr)}
.template-edit-page .template-workspace input:not([type=hidden]),.template-edit-page .template-workspace select{height:28px;min-height:28px;min-width:0;padding:3px 6px;margin:0;font-size:.78rem;line-height:1.2;border-radius:5px;box-sizing:border-box}
.template-edit-page .template-tree input[type=search]{margin:3px 0 5px}
.template-edit-page .template-tree .template-file{padding:2px 4px;margin:0;line-height:1.25}
.template-edit-page .template-group>summary,.template-edit-page .template-function>summary{padding:3px 0;font-size:.78rem}
.template-edit-page .template-preview-controls{grid-template-columns:1fr;gap:0}
.template-edit-page .template-split{gap:8px;margin-top:5px;align-items:start}
.template-edit-page .template-pane-heading{min-height:20px;margin-bottom:4px;gap:5px}
.template-edit-page .template-pane-heading h3{font-size:.86rem}
.template-edit-page .template-source-label{height:auto}
.template-edit-page .template-editor .template-source{height:auto;min-height:76px;max-height:60vh}
.template-edit-page .template-editor .template-source,.template-edit-page .template-source-highlight{padding:6px}
.template-edit-page .template-preview-pane .template-preview{height:auto;min-height:76px;max-height:60vh;padding:6px;margin:4px 0 0}
.template-edit-page [data-preview-status]:empty,.template-edit-page [data-template-status]:empty{display:none}
.template-edit-page [data-preview-status]{margin:3px 0;font-size:.74rem}
.template-edit-page .template-draft-actions,.template-edit-page .template-editor .connection-actions{display:inline-flex;align-items:center;flex-wrap:wrap;gap:4px;margin:5px 4px 0 0;padding:0}
.template-edit-page .template-workspace .button{min-height:28px;padding:4px 7px;font-size:.75rem;line-height:1.2;border-radius:5px}
.template-edit-page [data-editor-status]{font-size:.74rem}
@media(max-width:1100px){.template-edit-page .template-workspace{grid-template-columns:255px minmax(0,1fr)}.template-edit-page .template-combination label{grid-template-columns:120px minmax(0,1fr)}}
@media(max-width:700px){.template-edit-page .template-workspace{grid-template-columns:1fr}.template-edit-page .template-tree.panel{max-height:360px}.template-edit-page .template-combination label{grid-template-columns:128px minmax(0,1fr)}}
.template-edit-page .app-topbar .cc-appearance{display:flex;align-items:center;gap:4px;flex-wrap:nowrap}
.template-edit-page .app-topbar .cc-appearance select{height:28px;min-height:28px;max-width:135px;margin:0;padding:3px 6px}
.template-edit-page .template-tree.panel{gap:0}
.template-edit-page .template-combination label{grid-template-columns:140px minmax(0,1fr);white-space:nowrap}
.template-edit-page .template-code-actions{margin-top:4px}
.template-edit-page .template-tree summary{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* The editable text remains native and visible even when a theme overrides textarea styles. */
.template-edit-page .template-source-editor{isolation:isolate;background:#fffefa!important}
.template-edit-page .template-source-editor textarea.template-source{z-index:1;color:#202124!important;-webkit-text-fill-color:#202124!important;caret-color:#202124!important;background:transparent!important;opacity:1!important}
.template-edit-page .template-source-highlight{z-index:0;background:#fffefa!important;color:transparent!important;-webkit-text-fill-color:transparent!important}
.template-edit-page .template-source-highlight mark{color:transparent!important;-webkit-text-fill-color:transparent!important;background:#ffe680!important}
.template-edit-page .template-output-name{display:block;font:12px/1.4 Consolas,monospace;margin:6px 0 0;overflow-wrap:anywhere}
.template-edit-page .template-output-name[hidden]{display:none}

.template-edit-page .template-preview-files{max-height:60vh;overflow:auto;overscroll-behavior:contain}
.template-edit-page .template-preview-files .template-preview{max-height:none;overflow:visible;min-width:max-content}

/* Shared grid rows align both headings and both code surfaces below their controls. */
.template-edit-page .template-split{grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:auto auto auto auto;gap:0 8px}
.template-edit-page .template-code-pane,.template-edit-page .template-preview-pane,.template-edit-page [data-preview-content]{display:contents}
.template-edit-page .template-code-options{grid-column:1;grid-row:1;min-width:0;align-self:start}
.template-edit-page .template-preview-controls{grid-column:2;grid-row:1;min-width:0}
.template-edit-page .template-code-pane>.template-pane-heading{grid-column:1;grid-row:2}
.template-edit-page [data-preview-content]>.template-pane-heading{grid-column:2;grid-row:2}
.template-edit-page .template-source-label{grid-column:1;grid-row:3;min-width:0}
.template-edit-page .template-preview-body{grid-column:2;grid-row:3;min-width:0}
.template-edit-page .template-code-actions{grid-column:1;grid-row:4}
.template-edit-page .template-code-options .template-name-field{display:grid;grid-template-columns:max-content minmax(80px,240px);align-items:center;gap:5px;margin:0 0 3px;font-size:.76rem;line-height:1.2}
.template-edit-page .template-code-options .template-wrap-toggle{display:inline-flex;align-items:center;gap:5px;margin:0;font-size:.76rem;line-height:1.2;min-height:28px}
.template-edit-page .template-workspace input[type=checkbox]{width:14px;height:14px;min-height:14px;padding:0;flex:none}
.template-edit-page .template-preview-body .template-preview{margin-top:0}
.template-edit-page .template-editor.wrap-lines .template-source,.template-edit-page .template-editor.wrap-lines .template-source-highlight,.template-edit-page .template-editor.wrap-lines .template-preview,.template-edit-page .template-editor.wrap-lines .template-preview code{white-space:pre-wrap;overflow-wrap:anywhere;word-break:normal}
.template-edit-page .template-editor.wrap-lines .template-source{overflow-x:hidden}
.template-edit-page .template-editor.wrap-lines .template-preview{min-width:0;box-sizing:border-box;max-width:100%}
.template-edit-page .template-editor.wrap-lines .template-preview-files{overflow-x:hidden}
@media(max-width:900px){
 .template-edit-page .template-split{display:block}
 .template-edit-page .template-code-pane,.template-edit-page .template-preview-pane,.template-edit-page [data-preview-content]{display:block}
 .template-edit-page .template-preview-controls{margin-top:8px}
}

.template-pane-heading{display:flex;align-items:center;justify-content:space-between;gap:.75rem}
.template-pane-toggle .pane-restore{display:none}
.template-split section:is(:fullscreen,.pane-expanded){display:block;box-sizing:border-box;width:100%;height:100%;padding:1rem;background:Canvas;color:CanvasText;overflow:auto}
.template-split section.pane-expanded{position:fixed;inset:0;z-index:10000}
.template-split section:is(:fullscreen,.pane-expanded) .pane-expand{display:none}
.template-split section:is(:fullscreen,.pane-expanded) .pane-restore{display:inline}
.template-code-pane:is(:fullscreen,.pane-expanded) .template-source-editor,.template-code-pane:is(:fullscreen,.pane-expanded) .template-source{height:calc(100dvh - 14rem);max-height:none}
.template-preview-pane:is(:fullscreen,.pane-expanded) .template-preview-body,.template-preview-pane:is(:fullscreen,.pane-expanded) .template-preview-files,.template-preview-pane:is(:fullscreen,.pane-expanded) pre.template-preview{max-height:none}
.template-preview-pane:is(:fullscreen,.pane-expanded) [data-preview-content]{display:block}

body.template-edit-page:has(.template-workspace [aria-busy="true"]),body.template-edit-page:has(.template-workspace [aria-busy="true"]) *{cursor:wait!important}

.template-highlight-viewport{position:absolute;overflow:hidden;pointer-events:none;z-index:0}
.template-editor .template-highlight-viewport .template-source-highlight{position:static;inset:auto;width:100%;height:auto;max-height:none;min-height:0;overflow:visible;border:0;border-radius:0;margin:0;box-sizing:border-box}
.template-source-highlight mark{font:inherit;letter-spacing:inherit;padding:0;border:0;margin:0}
