/* Shared application shell. All colors used by the controls follow the active light/dark mode. */
:root, html[data-cc-appearance][data-design] {
    --studio-blue: #174fcc;
    --studio-link: #1344aa;
    --studio-tint: #e2edff;
    --studio-side: clamp(220px, 18vw, 280px);
    --color-accent: var(--studio-blue);
    --color-accent-ink: #fff;
    --color-accent-strong: #103c9d;
    --color-accent-soft: var(--studio-tint);
    --design-link: var(--studio-link);
    --teal: var(--studio-blue);
}
html[data-theme=dark] {
    --studio-link: #a3c5ff;
    --studio-tint: #243856;
}
html[data-cc-appearance][data-design=studio]:not([data-theme=dark]) {
    --color-paper: #f5f7fb;
    --color-paper-soft: #edf2f9;
    --color-panel: #fff;
    --color-header: #fff;
    --color-rule: #ced9e8;
    --color-rule-strong: #9bacc1;
    --color-ink: #203451;
    --color-muted: #4c5e77;
}
.studio-shell { display:grid; grid-template-columns:48px minmax(0,1fr); height:100vh; height:100dvh; }
.studio-rail { position:relative; z-index:8; display:flex; align-items:center; flex-direction:column;
    gap:5px; padding:7px 0; background:var(--color-paper-soft,var(--paper)); border-right:1px solid var(--line); }
.studio-rail a { display:grid; place-items:center; position:relative; width:36px; height:36px; border-radius:5px;
    color:var(--studio-link); font:600 21px/1 "Segoe UI Symbol",sans-serif; text-decoration:none; }
.studio-rail a:last-child { margin-top:auto; }
.studio-rail a:hover { background:var(--studio-tint); }
.studio-rail a[aria-current=page] { background:var(--studio-blue); color:white; }
.studio-rail a[aria-current=page]::before { content:""; position:absolute; left:-6px; width:3px; height:20px; background:var(--studio-blue); }
.rail-tip { position:absolute; left:calc(100% + 6px); top:50%; transform:translateY(-50%); pointer-events:none; display:none;
    white-space:nowrap; padding:6px 9px; color:white; background:#152946; font:500 13px/1.3 "Segoe UI",sans-serif; border-radius:4px; }
.studio-rail a:is(:hover,:focus) .rail-tip { display:block; }
.studio-shell :focus-visible { outline:2px solid var(--studio-link); outline-offset:2px; }
.studio-shell .app-workspace { min-height:0; min-width:0; }
.studio-shell .app-topbar { flex:none; justify-content:flex-start; min-height:44px; padding:4px 10px; gap:9px; border-bottom:1px solid var(--line); }
.studio-shell .app-tools { margin-left:auto; gap:7px; }
.studio-brand { display:inline-flex; align-items:center; gap:5px; color:var(--ink); font-weight:700; white-space:nowrap; }
.studio-brand small { font-size:.65em; letter-spacing:.12em; color:var(--studio-link); }
.studio-brand .brand-mark { background:var(--studio-blue); color:white; border:0; border-radius:5px; padding:5px; }
.studio-toggle { background:var(--white); color:var(--studio-link); cursor:pointer; border:1px solid var(--line); border-radius:4px; font:18px/1 sans-serif; padding:3px 6px; }
.studio-body { display:grid; grid-template-columns:var(--studio-side) minmax(0,1fr); min-height:0; flex:1; overflow:auto; align-items:start; }
.studio-body.editor-body,.context-folded .studio-body { grid-template-columns:minmax(0,1fr); }
.studio-context { align-self:stretch; position:sticky; top:0; padding:10px; border-right:1px solid var(--line);
    background:var(--color-paper-soft,var(--paper)); max-height:100%; overflow:auto; }
.studio-context h2 { font-size:1.05em; margin:0 0 8px; }
.studio-context a { display:block; padding:5px 7px; color:var(--ink); border-radius:4px; }
.studio-context a:is([aria-current=page],:hover) { color:var(--studio-link); background:var(--studio-tint); }
.studio-context a[aria-current=page] { box-shadow:inset 3px 0 var(--studio-blue); font-weight:650; }
.studio-shell.context-folded #studio-context { display:none; }
.studio-account { position:relative; }
.studio-account summary { cursor:pointer; }
.studio-account>div { position:absolute; z-index:9; right:0; min-width:150px; padding:8px; border:1px solid var(--line); background:var(--white); }
.studio-shell .app-footer { margin:0; padding:3px 10px; font-size:.85em; border-top:1px solid var(--line); }
.app-layout .studio-shell .app-content { padding:8px 10px 12px; }
.studio-shell .app-content .panel { border-radius:5px; padding:9px; margin-bottom:8px; }
.studio-shell .app-content .page-heading { margin:0 0 7px; gap:7px; }
.studio-shell .app-content h1 { font-size:calc(21px * var(--cc-text-scale,1)); }
.studio-shell .app-content :is(th,td) { padding:5px 7px; }
.studio-shell .app-content .button { min-height:26px; padding:4px 8px; border-radius:4px; }
.template-edit-page .studio-shell .template-workspace { grid-template-columns:var(--studio-side) minmax(0,1fr); align-items:start; gap:8px; }
.template-edit-page .studio-shell.context-folded .template-workspace { grid-template-columns:minmax(0,1fr); }
.template-edit-page .studio-shell .template-tree.panel { position:sticky; top:0; max-height:calc(100dvh - 100px); min-height:0; background:var(--color-paper-soft,var(--paper)); }
.studio-shell .template-tree-files { min-height:60px; overflow:auto; }
.template-edit-page .studio-shell .template-file { padding:3px 5px; font:inherit; width:100%; color:var(--ink); }
.studio-shell .template-tree .template-file>span:last-child { white-space:normal; overflow-wrap:anywhere; text-align:start; }
.studio-shell .template-tree .template-file[aria-current=true] { background:var(--studio-tint); color:var(--studio-link); box-shadow:inset 3px 0 var(--studio-blue); }
.template-edit-page .studio-shell .template-combination label { grid-template-columns:minmax(0,1.25fr) minmax(0,1fr); white-space:normal; }
@media(max-width:820px) {
    .studio-shell .app-location>span,.studio-brand small { display:none; }
    .studio-shell .app-topbar { flex-wrap:wrap; }
    .studio-shell .app-tools { flex-wrap:wrap; max-width:100%; }
}
@media(max-width:760px) {
    .studio-shell { grid-template-columns:39px minmax(0,1fr); }
    .studio-rail a { width:30px; height:32px; }
    .studio-body,.template-edit-page .studio-shell .template-workspace { grid-template-columns:minmax(0,1fr); }
    .studio-context,.template-edit-page .studio-shell .template-tree.panel { position:static; max-height:56dvh; }
    .studio-shell .app-topbar .cc-appearance select { max-width:95px; }
    .studio-shell .app-footer { flex-wrap:wrap; gap:5px; }
    .studio-shell .app-footer>span:last-child { display:none; }
}

.studio-rail svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.65; stroke-linecap:round; stroke-linejoin:round; }
html .studio-shell .studio-brand .brand-mark { color:white; background:var(--studio-blue); }
html .studio-shell .button.secondary,html .creation-modal .button.secondary { color:var(--studio-link); }
.studio-shell .template-tree .template-count { font-variant-numeric:tabular-nums; }
.template-edit-page .studio-shell .template-tree summary { white-space:normal; }
@media(min-width:761px) {
    .template-edit-page .template-code-pane:not(:fullscreen):not(.pane-expanded) .template-source,
    .template-edit-page .template-preview-pane:not(:fullscreen):not(.pane-expanded) .template-preview-files {
        max-height:clamp(180px,calc(100dvh - 336px),68dvh);
    }
}

studio-splitter { display:none; }
@media (min-width:761px) {
    .studio-shell:not(.context-folded) .studio-body:not(.editor-body):has(> studio-splitter:defined),
    .template-edit-page .studio-shell:not(.context-folded) .template-workspace:has(> studio-splitter:defined) {
        grid-template-columns:var(--studio-side) 10px minmax(0,1fr);
        column-gap:0;
    }
    .studio-shell:not(.context-folded) studio-splitter:defined {
        display:grid; place-items:stretch center; align-self:stretch;
        touch-action:none; cursor:col-resize; user-select:none;
    }
    studio-splitter::before { content:""; width:2px; background:var(--line); }
    studio-splitter:is(:hover,:focus-visible)::before,.resizing-panel studio-splitter::before {
        width:3px; background:var(--studio-blue);
    }
    .resizing-panel { user-select:none; cursor:col-resize; }
}
.template-edit-page .studio-shell .template-tree-files summary { cursor:pointer; line-height:1.3; }
.template-edit-page .studio-shell .template-section { border-bottom:1px solid var(--line); padding:2px 0; }
.template-edit-page .studio-shell .template-section > summary { font-size:.95rem; font-weight:700; padding:4px 0; }
.template-edit-page .studio-shell .template-section details {
    margin-inline-start:7px; padding:0 0 0 6px; border:0; border-inline-start:1px solid var(--line);
}
.template-edit-page .studio-shell .template-group > summary { font-size:.88rem; font-weight:650; padding:3px 0; }
.template-edit-page .studio-shell .template-function > summary { font-size:.84rem; font-weight:600; padding:2px 0; }
.template-edit-page .studio-shell .template-tree .template-file {
    width:calc(100% - 8px); margin-inline-start:8px; padding:3px 4px;
    font-size:.81rem; font-weight:400; line-height:1.3; align-items:baseline;
}
.template-edit-page .template-tree .template-count { font-size:.76em; color:var(--muted); }
