/* Construction editor. Uses the established P1 palette; no independent brand. */
@media(min-width:701px){dialog.construction-modal{max-width:1100px}}
.construction-editor{min-width:0;border:1px solid var(--line);border-radius:12px;overflow:hidden;background:var(--paper);color:var(--ink)}
.ce-header{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;padding:20px 22px;border-bottom:1px solid var(--line);background:var(--white)}
.ce-header h3{font-size:19px;font-weight:650;letter-spacing:-.5px}
.ce-header p{font-size:11px;color:var(--muted);margin-top:4px;max-width:620px}
.ce-step{display:inline-flex;align-items:center;gap:7px;font-size:10px;font-weight:650;color:var(--primary);text-transform:uppercase;letter-spacing:1px;margin-bottom:7px}
.ce-step:before{content:"";width:7px;height:7px;border-radius:50%;background:var(--primary)}
.ce-kind{display:flex;gap:6px;flex-wrap:wrap;padding:14px 22px;background:var(--white);border-bottom:1px solid var(--line)}
.ce-kind button,.ce-section-tab{border:1px solid var(--border);border-radius:7px;background:var(--white);color:var(--ink);font-size:11px;font-weight:600;line-height:1.35;min-height:35px;padding:8px 11px}
.ce-kind button[aria-pressed="true"],.ce-section-tab[aria-pressed="true"]{background:var(--accent);border-color:var(--ink);text-decoration:underline;text-underline-offset:3px}
.ce-kind button:hover:not(:disabled),.ce-section-tab:hover:not(:disabled){background:var(--soft)}
.ce-kind button[aria-pressed="true"]:hover,.ce-section-tab[aria-pressed="true"]:hover{background:var(--accent)}
.ce-gallery-wrap{padding:16px 22px;border-bottom:1px solid var(--line);background:var(--white)}
.ce-gallery-title{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:11px;font-size:11px;color:var(--muted)}
.ce-gallery-title strong{color:var(--ink);font-size:12px}
.ce-gallery{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;min-width:0}
.ce-template{position:relative;display:flex;flex-direction:column;text-align:left;gap:7px;min-width:0;min-height:130px;padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--white);color:var(--ink)}
.ce-template:hover:not(:disabled){border-color:var(--primary);background:var(--paper)}
.ce-template[aria-pressed="true"]{border:2px solid var(--primary);padding:9px;background:var(--paper)}
.ce-template[aria-pressed="true"]:after{position:absolute;right:7px;top:5px;content:"✓";font-size:13px;font-weight:800;color:var(--primary)}
.ce-template-code{font-size:9px;font-weight:700;letter-spacing:.7px;color:var(--primary)}
.ce-template-name{font-size:10px;font-weight:550;line-height:1.4;overflow-wrap:anywhere}
.ce-template-preview{display:block;width:100%;height:57px;pointer-events:none}
.ce-template-preview svg{display:block;width:100%;height:100%;max-width:100%}
.ce-workspace{display:grid;grid-template-columns:minmax(0,1fr) 285px;min-width:0}
.ce-canvas-panel{padding:20px 22px;min-width:0;display:flex;flex-direction:column;gap:12px}
.ce-canvas-head{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;position:sticky;top:0;z-index:1;background:var(--paper);padding:5px 0}
.ce-canvas-head h4{font-size:13px;margin:0;font-weight:650;overflow-wrap:anywhere}
.ce-item-identity{font-size:11px;font-weight:650;color:var(--primary);overflow-wrap:anywhere;margin-bottom:4px}
.ce-viewpoint{font-size:9px;color:var(--muted);border:1px solid var(--line);border-radius:5px;padding:4px 6px;white-space:nowrap}
.ce-canvas{display:grid;place-items:center;min-height:280px;max-height:490px;aspect-ratio:1.3;background:var(--white);border:1px solid var(--line);border-radius:9px;overflow:hidden;min-width:0}
.ce-canvas>svg{display:block;width:100%;height:100%;max-width:100%;max-height:490px}
.ce-canvas [data-section]{cursor:pointer;outline:none}
.ce-canvas [data-section]:focus-visible{outline:3px solid var(--primary);outline-offset:2px}
.ce-canvas [data-section][aria-pressed="true"]{--section-selected:var(--primary)}
.ce-section-list{display:flex;flex-wrap:wrap;gap:5px}
.ce-section-tab{min-width:36px;font-size:10px;padding:7px 9px}
.ce-canvas-caption{font-size:10px;line-height:1.6;color:var(--muted)}
.ce-selected-summary{display:flex;flex-wrap:wrap;align-items:center;gap:7px;font-size:10px;color:var(--muted)}
.ce-selected-summary strong{color:var(--primary);font-weight:650}
.ce-badge{border:1px solid var(--line);background:var(--white);padding:4px 7px;border-radius:5px;font-size:10px}
.ce-inspector{padding:20px 18px;border-left:1px solid var(--line);background:var(--white);min-width:0;display:grid;align-content:start;gap:14px}
.ce-inspector h4{margin:0;font-size:13px;line-height:1.4}
.ce-inspector h5{margin:3px 0 0;font-size:11px;font-weight:650;color:var(--muted)}
.ce-inspector label{font-size:10px;gap:6px;min-width:0}
.ce-inspector input,.ce-inspector select{font-size:12px;min-height:38px;padding:8px 9px}
.ce-inspector .ce-checkbox{display:flex;align-items:center;gap:8px;line-height:1.5;color:var(--ink)}
.ce-checkbox input{width:17px;min-height:17px;height:17px;flex-shrink:0;accent-color:var(--primary);margin:0}
.ce-field-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}
.ce-field-help{font-size:9px;color:var(--muted);line-height:1.65}
.ce-control-divider{height:1px;background:var(--line);margin:2px 0}
.ce-action-row{display:flex;gap:6px;flex-wrap:wrap}
.construction-editor .ce-button{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:35px;padding:8px 10px;border:1px solid var(--border);border-radius:7px;background:var(--white);color:var(--ink);font-size:10px;font-weight:600;line-height:1.45;white-space:normal;text-align:center}
.construction-editor .ce-button:hover:not(:disabled){background:var(--soft)}
.construction-editor .ce-button-primary{background:var(--primary);color:var(--white);border-color:var(--primary)}
.construction-editor .ce-button-primary:hover:not(:disabled){background:var(--hover);border-color:var(--hover)}
.construction-editor .ce-button-danger{color:var(--danger);border-color:var(--danger)}
.construction-editor button:disabled{cursor:wait;background:var(--soft);color:var(--muted)}
.ce-confirm{margin:16px 22px 0;padding:15px;border:1px solid var(--danger);border-radius:9px;background:var(--white);display:grid;gap:9px}
.ce-confirm[hidden],.construction-editor [hidden]{display:none!important}
.ce-confirm h4{margin:0;font-size:13px;color:var(--danger)}
.ce-confirm p{font-size:11px;line-height:1.6;color:var(--ink)}
.ce-confirm .ce-action-row{margin-top:2px}
.ce-system-fields{padding:18px 22px;border-top:1px solid var(--line);display:grid;gap:12px;background:var(--white)}
.ce-system-fields h4{margin:0;font-size:12px}
.ce-system-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.ce-system-grid label{font-size:10px}
.ce-system-grid input,.ce-system-grid select{font-size:12px;min-height:38px;padding:8px 9px}
.ce-system-grid .ce-checkbox{display:flex;align-items:center;gap:8px}
.ce-safety{margin:0;padding:12px 22px;background:var(--soft);border-top:1px solid var(--line);font-size:10px;line-height:1.65;color:var(--ink)}
.ce-empty{padding:30px 22px;text-align:center;display:grid;gap:14px;justify-items:center;background:var(--white)}
.ce-empty p{max-width:510px;font-size:12px;line-height:1.7;color:var(--muted)}
.ce-empty h4{margin:0;font-size:16px}
.ce-error{margin:0 22px 14px;font-size:11px;color:var(--danger);line-height:1.6}
.ce-error:empty{display:none}
.ce-equal-note{padding:9px 11px;background:var(--paper);border:1px dashed var(--border);border-radius:6px;font-size:10px;color:var(--muted);line-height:1.6}
.ce-live-note{font-size:10px;color:var(--muted);min-height:15px}
.ce-config-warning{font-size:11px;color:var(--danger);line-height:1.6}
.ce-config-warning:empty{display:none}
.ce-invalid{border-color:var(--danger)!important}
@media(max-width:900px){
  .ce-gallery{grid-template-columns:repeat(4,minmax(0,1fr))}
  .ce-workspace{grid-template-columns:minmax(0,1fr) 250px}
  .ce-canvas-panel{padding:18px}
  .ce-inspector{padding:18px 15px}
  .ce-canvas{min-height:240px}
  .ce-header,.ce-kind,.ce-gallery-wrap,.ce-system-fields{padding-left:18px;padding-right:18px}
}
@media(max-width:700px){
  .ce-header{padding:16px 14px}
  .ce-header h3{font-size:17px}
  .ce-header p{font-size:10px}
  .ce-kind,.ce-gallery-wrap{padding:12px 14px}
  .ce-gallery{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  .ce-template{padding:8px;min-height:121px}
  .ce-template[aria-pressed="true"]{padding:7px}
  .ce-template-name{font-size:9px}
  .ce-template-preview{height:51px}
  .ce-workspace{grid-template-columns:minmax(0,1fr)}
  .ce-canvas-panel{padding:17px 14px}
  .ce-canvas{min-height:230px;max-height:370px;aspect-ratio:1.15}
  .ce-canvas>svg{max-height:370px}
  .ce-inspector{border-left:0;border-top:1px solid var(--line);padding:17px 14px;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:13px 11px}
  .ce-inspector>h4,.ce-inspector>h5,.ce-inspector>.ce-control-divider,.ce-inspector>.ce-field-help,.ce-inspector>.ce-action-row,.ce-inspector>.ce-equal-note,.ce-inspector>.ce-field-row,.ce-inspector>.ce-live-note{grid-column:1/-1}
  .ce-inspector input,.ce-inspector select,.ce-system-grid input,.ce-system-grid select{font-size:16px;min-height:42px}
  .ce-system-fields{padding:17px 14px}
  .ce-system-grid{grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}
  .ce-confirm{margin:14px 14px 0;padding:12px}
  .ce-safety{padding:12px 14px;font-size:9px}
  .ce-error{margin-left:14px;margin-right:14px}
  .ce-viewpoint{font-size:8px}
}
@media(max-width:390px){
  .ce-header,.ce-kind,.ce-gallery-wrap,.ce-canvas-panel,.ce-inspector,.ce-system-fields{padding-left:11px;padding-right:11px}
  .ce-gallery{grid-template-columns:repeat(2,minmax(0,1fr))}
  .ce-template{min-height:115px}
  .ce-kind button{font-size:10px;padding:7px 8px}
  .ce-canvas-head{flex-wrap:wrap}
  .ce-system-grid{grid-template-columns:minmax(0,1fr)}
  .ce-inspector{grid-template-columns:minmax(0,1fr)}
  .ce-inspector>*{grid-column:1!important}
  .ce-canvas{min-height:210px}
}
@media print{.construction-editor{display:none!important}}

/* Separate permanent regions: switching a tab or viewport never swaps inputs. */
.ce-section-editor,.ce-dimensions{display:grid;align-content:start;gap:14px;min-width:0}
.ce-dimensions{border-top:1px solid var(--line);padding-top:18px}
.ce-section-editor h4,.ce-dimensions h4{margin:0;font-size:13px}
.ce-panel-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;min-width:0}
.ce-panel-heading strong{font-size:12px}
.ce-panel-heading p{font-size:10px;color:var(--muted);margin-top:4px}
.ce-gallery-wrap>.ce-panel-heading{margin-bottom:14px}
.ce-catalog-launch,.ce-mobile-backdrop,.ce-empty-dimensions,.construction-editor .ce-panel-close,.construction-editor .ce-section-done{display:none}
.ce-system-details{border-top:1px solid var(--line);background:var(--white);min-width:0}
.ce-system-details>summary{padding:16px 22px;min-height:48px;cursor:pointer;font-size:12px;font-weight:650;list-style-position:inside;color:var(--ink)}
.ce-system-details>summary:hover{background:var(--paper)}
.ce-system-details>.ce-system-fields{border-top:1px solid var(--line)}
.ce-system-grid:empty{display:none}
@media(max-width:700px){
  .construction-editor{overflow:visible;border-radius:10px}
  .ce-header{display:none}
  .ce-catalog-launch{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:12px 14px;background:var(--white);border-radius:10px 10px 0 0;border-bottom:1px solid var(--line)}
  .ce-catalog-launch>span{font-size:12px;font-weight:700;color:var(--primary)}
  .construction-editor .ce-catalog-launch>.ce-button{font-size:12px;min-height:44px;padding:10px 14px}
  .ce-workspace{display:block}
  .ce-canvas-panel{padding:13px 14px;gap:10px}
  .ce-canvas-head{position:static;padding:0}
  .ce-canvas-head h4{font-size:12px}
  .ce-canvas{min-height:230px;max-height:390px;aspect-ratio:1.18}
  .ce-canvas>svg{max-height:390px}
  .ce-section-list{gap:6px}
  .ce-section-tab{min-width:44px;min-height:44px;font-size:12px}
  .ce-canvas-caption{font-size:11px}
  .ce-live-note:empty{display:none}
  .ce-inspector{display:contents;padding:0;border:0}
  .ce-section-editor,.ce-gallery-wrap{display:none}
  .ce-dimensions{border:0;padding:16px 14px;gap:14px;background:var(--white);border-radius:10px}
  .ce-dimensions h4{font-size:15px}
  .ce-dimensions label,.ce-section-editor label{font-size:12px}
  .ce-dimensions input,.ce-dimensions select,.ce-section-editor input,.ce-section-editor select{font-size:16px;min-height:46px;padding:10px 12px}
  .ce-dimensions .ce-field-help,.ce-section-editor .ce-field-help{font-size:11px;line-height:1.65}
  .ce-dimensions .ce-equal-note{font-size:11px}
  .ce-dimensions .ce-button{min-height:44px;font-size:11px}
  .ce-system-details>summary{padding:15px 14px;font-size:13px;min-height:48px}
  .ce-system-fields{padding:15px 14px}
  .ce-system-fields .ce-field-help{font-size:11px}
  .ce-system-grid label{font-size:12px}
  .ce-system-grid input,.ce-system-grid select{min-height:46px}
  .ce-system-fields .ce-button{min-height:44px;font-size:11px}
  .ce-system-grid .ce-checkbox{min-height:40px}
  .ce-system-grid .ce-checkbox input{min-height:20px;height:20px;width:20px}
  .ce-safety{font-size:10px}
  /* These fixed panels belong to the existing top-layer form dialog. */
  .construction-editor[data-ce-overlay="catalog"]>.ce-mobile-backdrop,
  .construction-editor[data-ce-overlay="section"]>.ce-mobile-backdrop{display:block;position:fixed;inset:0;z-index:50;border:0;border-radius:0;background:color-mix(in srgb,var(--ink) 60%,transparent);padding:0;cursor:default}
  .construction-editor[data-ce-overlay="catalog"]>.ce-gallery-wrap{display:block;position:fixed;inset:auto 8px 8px;max-height:calc(100dvh - 32px);overflow-y:auto;overscroll-behavior:contain;z-index:51;padding:0 14px 18px;border:1px solid var(--border);border-radius:18px;background:var(--white);box-shadow:0 18px 55px color-mix(in srgb,var(--ink) 25%,transparent)}
  .construction-editor[data-ce-overlay="section"] .ce-section-editor{display:grid;position:fixed;inset:auto 8px 8px;max-height:calc(85dvh - 16px);overflow-y:auto;overscroll-behavior:contain;z-index:51;padding:0 18px max(18px,env(safe-area-inset-bottom));border:1px solid var(--border);border-radius:18px;background:var(--white);gap:17px;box-shadow:0 18px 55px color-mix(in srgb,var(--ink) 25%,transparent)}
  .construction-editor[data-ce-overlay="catalog"]>.ce-gallery-wrap,
  .construction-editor[data-ce-overlay="section"] .ce-section-editor{bottom:max(8px,calc(100dvh - var(--opening-viewport-height,100dvh) - var(--opening-viewport-top,0px) + 8px));max-height:calc(var(--opening-viewport-height,100dvh) - 32px)}
  .construction-editor .ce-panel-close{display:inline-flex;flex-shrink:0;min-height:44px;max-width:110px;font-size:11px;padding:8px 11px}
  .construction-editor .ce-section-done{display:inline-flex;min-height:46px;font-size:13px;margin-top:2px}
  .ce-panel-heading{position:sticky;top:0;z-index:2;align-items:center;background:var(--white);padding:16px 0 12px;border-bottom:1px solid var(--line)}
  .ce-panel-heading strong,.ce-panel-heading h4{font-size:14px}
  .ce-panel-heading p{font-size:10px;line-height:1.5}
  .ce-gallery-wrap>.ce-panel-heading{margin-bottom:14px}
  .ce-gallery{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .ce-template{min-height:139px;padding:10px}
  .ce-template[aria-pressed="true"]{padding:9px}
  .ce-template-name{font-size:11px;line-height:1.4}
  .ce-template-preview{height:69px}
  .ce-template-code{font-size:10px}
  .ce-empty{padding:24px 16px}
  .ce-confirm{margin:12px 14px;padding:14px}
  .ce-confirm .ce-button{min-height:44px;font-size:11px}
  form:not([data-mobile-tab="dimensions"]) .ce-dimensions{display:none}
  form[data-mobile-tab="dimensions"] .construction-editor>.ce-catalog-launch,
  form[data-mobile-tab="dimensions"] .construction-editor>.ce-gallery-wrap,
  form[data-mobile-tab="dimensions"] .construction-editor>.ce-mobile-backdrop,
  form[data-mobile-tab="dimensions"] .construction-editor>.ce-confirm,
  form[data-mobile-tab="dimensions"] .ce-canvas-panel,
  form[data-mobile-tab="dimensions"] .ce-section-editor,
  form[data-mobile-tab="dimensions"] .ce-system-details,
  form[data-mobile-tab="dimensions"] .construction-editor>.ce-empty,
  form[data-mobile-tab="dimensions"] .construction-editor>.ce-safety{display:none!important}
  form[data-mobile-tab="dimensions"] .ce-empty-dimensions{display:block;padding:18px;font-size:12px;color:var(--muted);line-height:1.7}
  form[data-mobile-tab="photos"] .construction-editor{display:none!important}
}
@media(max-width:390px){
  .ce-dimensions,.ce-canvas-panel,.ce-catalog-launch{padding-left:11px;padding-right:11px}
  .construction-editor[data-ce-overlay="section"] .ce-section-editor{padding-left:14px;padding-right:14px}
  .ce-gallery{gap:8px}
  .ce-template{min-height:139px}
  .ce-panel-heading{gap:8px}
  .ce-panel-heading strong,.ce-panel-heading h4{font-size:13px}
}
/* A compact header leaves the fields reachable above an on-screen keyboard. */
@media(max-width:700px) and (max-height:520px){
  .ce-panel-heading{padding:8px 0;gap:10px;min-height:60px}
  .ce-gallery-wrap>.ce-panel-heading{margin-bottom:10px}
  .ce-gallery-wrap .ce-panel-heading p{display:none}
  .ce-template{min-height:112px;gap:5px}
  .ce-template-preview{height:48px}
  .ce-template-name{font-size:10px}
  .ce-canvas{min-height:160px;max-height:250px}
  .ce-canvas>svg{max-height:250px}
  .construction-editor[data-ce-overlay="section"] .ce-section-editor{gap:11px}
}
@media(min-width:480px) and (max-width:700px) and (max-height:520px){
  .ce-gallery{grid-template-columns:repeat(3,minmax(0,1fr))}
  .construction-editor[data-ce-overlay="section"] .ce-section-editor{grid-template-columns:repeat(2,minmax(0,1fr))}
  .ce-section-editor>.ce-panel-heading,.ce-section-editor>.ce-field-help,.ce-section-editor>.ce-section-done{grid-column:1/-1}
}
