/* Controls follow the supplied reference; document layout stays with documents.js. */
.template-editor{--tp-text:#1A202C;--tp-muted:#64748B;--tp-border:#E2E6EE;--tp-strong:#CBD2DC;--tp-soft:#F1F3F7;--tp-primary:#114f80;color:var(--tp-text);max-width:1200px}
.template-editor *, .template-editor *::before,.template-editor *::after{box-sizing:border-box}
#main #restored-settings .template-editor button{font:inherit;cursor:pointer;letter-spacing:normal;text-transform:none;box-shadow:none}
.template-editor svg{width:20px;height:20px;flex-shrink:0;vertical-align:middle}
.template-editor .tp-top{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:16px}
.template-editor .tp-title-wrap{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
#main #restored-settings .template-editor h2{font-size:20px;font-weight:600;margin:0;line-height:1.3;color:var(--tp-text)}
.template-editor .tp-status{font-size:13px;color:#17763e;display:flex;align-items:center;gap:5px}
.template-editor .tp-status svg{width:16px;height:16px}
.template-editor .tp-seg{display:inline-flex;padding:3px;border-radius:10px;background:var(--tp-soft);gap:2px;max-width:100%;flex-wrap:wrap}
#main #restored-settings .template-editor .tp-seg button{display:flex;align-items:center;justify-content:center;gap:5px;padding:7px 14px;min-height:34px;border:0;background:transparent;font-size:14px;border-radius:8px;color:var(--tp-muted);white-space:nowrap}
#main #restored-settings .template-editor .tp-seg button[aria-pressed=true]{background:#fff;color:var(--tp-primary);font-weight:600;box-shadow:0 0 0 1px var(--tp-border)}
#main #restored-settings .template-editor .tp-seg button:hover{background:#fff}
.template-editor .tp-controls{margin:0;max-width:none}
.template-editor .tp-acc{border:1px solid var(--tp-border);border-radius:12px;margin-bottom:10px;overflow:hidden}
#main #restored-settings .template-editor .tp-acc h3{margin:0;padding:0;font:inherit;border:0}
#main #restored-settings .template-editor .tp-acc-head{display:flex;align-items:center;gap:14px;padding:14px 16px;width:100%;border:0;border-radius:0;background:#fff;color:var(--tp-text);text-align:left;min-height:52px}
#main #restored-settings .template-editor .tp-acc-head:hover{background:#FAFBFC}
.template-editor .tp-acc-head>svg{width:22px;height:22px;color:var(--tp-muted)}
.template-editor .tp-acc-title{flex:0 0 170px;font-size:15px;font-weight:600}
.template-editor .tp-summary{flex:1;min-width:0;font-size:14px;font-weight:400;color:var(--tp-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.template-editor .tp-acc-head[aria-expanded=true] .tp-summary{visibility:hidden}
.template-editor .tp-toggle{font-size:14px;font-weight:400;color:var(--tp-primary);display:flex;align-items:center;gap:4px;margin-left:auto;flex-shrink:0}
.template-editor .tp-toggle svg{width:16px;height:16px}
.template-editor [aria-expanded=true] .tp-toggle svg{transform:rotate(180deg)}
.template-editor .tp-acc-body{padding:4px 16px 18px 52px}
.template-editor [hidden],.template-paper [hidden]{display:none!important}
.template-editor .tp-grid-kop{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.6fr);gap:16px;margin-bottom:18px}
.template-editor .tp-logo-row{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:10px;background:var(--tp-soft);margin-bottom:12px;font-size:14px}
.template-editor .tp-logo-thumb{width:32px;height:32px;object-fit:contain}
#main #restored-settings .template-editor .tp-switch{margin-left:auto;flex-shrink:0;position:relative;width:36px;min-width:36px;height:20px;min-height:20px;border:0;padding:0;border-radius:999px;background:var(--tp-primary)}
.template-editor .tp-switch span{position:absolute;top:2px;left:18px;width:16px;height:16px;border-radius:50%;background:#fff}
#main #restored-settings .template-editor .tp-switch[aria-checked=false]{background:#64748B}
.template-editor .tp-switch[aria-checked=false] span{left:2px}
#main #restored-settings .template-editor .tp-field{display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--tp-muted);margin:0;font-weight:400;min-width:0}
#main #restored-settings .template-editor input[type=text],#main #restored-settings .template-editor textarea{font:inherit;font-size:14px;padding:9px 11px;border-radius:8px;border:1px solid var(--tp-strong);color:var(--tp-text);resize:vertical;min-width:0;width:100%;background:#fff;min-height:0;line-height:1.5;margin:0}
.template-editor .tp-grid-slider{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:18px 28px}
.template-editor .tp-slider{display:flex;flex-direction:column;gap:6px;min-width:0;font-weight:400}
.template-editor .tp-slider-head{display:flex;justify-content:space-between;align-items:baseline;font-size:13px;color:var(--tp-muted);gap:8px}
.template-editor .tp-slider-head b{font-weight:600;font-size:15px;color:var(--tp-text);font-variant-numeric:tabular-nums;white-space:nowrap}
.template-editor .tp-slider-head em{font-style:normal;font-weight:400;font-size:12px;color:var(--tp-muted)}
#main #restored-settings .template-editor input[type=range]{width:100%;accent-color:var(--tp-primary);cursor:pointer;margin:0;padding:0;border:0;min-height:24px;height:24px;box-shadow:none;background:transparent}
.template-editor .tp-swatches{display:flex;gap:10px;align-items:center;min-height:35px}
#main #restored-settings .template-editor .tp-swatch{width:26px;min-width:26px;height:26px;min-height:26px;padding:0;border-radius:50%;cursor:pointer;background:var(--swatch);border:1px solid #0002}
#main #restored-settings .template-editor .tp-swatch[aria-pressed=true]{box-shadow:0 0 0 2px #fff,0 0 0 4px var(--tp-primary)}
.template-editor .tp-logo-pos{display:flex}
#main #restored-settings .template-editor .tp-logo-pos button{flex:1;padding:7px 8px;font-size:13px}
.template-editor .tp-logo-pos svg{width:16px;height:16px}
.template-editor .tp-chips{display:flex;flex-wrap:wrap;gap:8px}
#main #restored-settings .template-editor .tp-chip{display:flex;align-items:center;gap:5px;font-size:14px;padding:6px 12px;min-height:34px;border-radius:999px;border:1px solid #9DBEF5;background:#E6EFFD;color:var(--tp-primary)}
#main #restored-settings .template-editor .tp-chip[aria-pressed=false]{background:transparent;border-color:var(--tp-strong);color:var(--tp-muted)}
.template-editor .tp-chip svg{width:16px;height:16px}
.template-editor .tp-chip[aria-pressed=false] svg{display:none}
.template-editor .tp-footer{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin-top:6px}
#main #restored-settings .template-editor .tp-ghost{display:flex;align-items:center;gap:6px;font-size:14px;padding:8px 14px;border-radius:8px;border:1px solid var(--tp-strong);background:#fff;color:var(--tp-text)}
#main #restored-settings .template-editor .tp-ghost:hover{background:var(--tp-soft)}
.template-editor .tp-canvas{margin-top:16px;background:var(--tp-soft);border-radius:14px;padding:24px 16px;overflow:hidden;min-width:0}
.template-editor .tp-fit{position:relative;margin:0 auto}
.template-editor .tp-fit>.print-page{position:absolute;top:0;left:0;transform-origin:top left;width:210mm;min-height:297mm;box-shadow:0 1px 3px #0002;margin:0;background:#fff}
.template-paper{padding:var(--tp-margin)!important;font-size:var(--tp-font)!important}
.template-paper .print-head{border-color:var(--tp-color);flex-direction:row}
.template-paper[data-layout=right] .print-head{flex-direction:row-reverse}
.template-paper[data-layout=right] .letterhead-copy{text-align:right}
.template-paper[data-layout=center] .print-head{flex-direction:column;text-align:center}
.template-paper[data-layout=center] .letterhead-copy{text-align:center}
.template-paper .print-head img{width:var(--tp-logo-size)!important;height:var(--tp-logo-size)!important}
.template-paper[data-logo=false] .print-head img{display:none}
.template-paper .print-head h2{font-size:var(--tp-heading)!important;color:var(--tp-color)!important}
.template-paper .print-head .letterhead-address{font-size:var(--tp-address)!important}
.template-paper h1{font-size:var(--tp-title)!important;color:var(--tp-color)!important}
.template-paper h3{font-size:var(--tp-section)!important;color:var(--tp-color)!important}
.template-paper .document-pairs dt,.template-paper .document-pairs dd,.template-paper p,.template-paper footer{font-size:var(--tp-font)}
.template-paper table th,.template-paper table td{font-size:var(--tp-table)!important}
#main #restored-settings .template-editor :focus-visible{outline:2px solid var(--tp-primary);outline-offset:3px}
@media(max-width:700px){.template-editor .tp-acc-title{flex-basis:135px}.template-editor .tp-acc-head{gap:10px}.template-editor .tp-summary{font-size:12px}.template-editor .tp-acc-body{padding-left:16px}.template-editor .tp-grid-kop{grid-template-columns:1fr}.template-editor .tp-grid-slider{grid-template-columns:1fr}.template-editor .tp-title-wrap{gap:8px}.template-editor .tp-top>.tp-seg{width:100%}#main #restored-settings .template-editor .tp-top>.tp-seg button{flex:1;font-size:13px;padding:7px 9px}}
@media(max-width:480px){.template-editor .tp-acc-head{flex-wrap:wrap;gap:8px;padding:12px}.template-editor .tp-acc-title{flex:1}.template-editor .tp-summary{order:4;flex-basis:100%;padding-left:30px}.template-editor .tp-acc-head[aria-expanded=true] .tp-summary{display:none}.template-editor .tp-canvas{padding:16px 8px}.template-editor .tp-footer{align-items:stretch}#main #restored-settings .template-editor .tp-ghost{font-size:12px;padding:8px 10px}}
