/* Covers retain their real aspect ratio at every card width. */
#templates .template-cover{display:block;width:100%;height:auto;aspect-ratio:16/9;padding:0;border:0;background:#f3f4f8;cursor:pointer;text-align:left}
#templates .template-cover>svg,#templatePreviewStage>svg{display:block;width:100%;height:100%}
#templates .template-grid{align-items:stretch;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px}
#templates .template-card{display:flex;flex-direction:column;border-radius:12px;box-shadow:0 3px 12px #17203306;transition:box-shadow .15s,border-color .15s}
#templates .template-card:hover{border-color:#c9c4eb;box-shadow:0 6px 20px #17203310}
#templates .template-info{display:flex;flex:1;flex-direction:column;padding:16px}
#templates .template-info>b{font-size:14px;line-height:1.5;color:#25283a}
#templates .template-info>p{font-size:12px;line-height:1.6;margin:8px 0 16px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
#templates .template-footer{margin-top:auto;gap:10px}
#templates .template-footer .tag{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#templates .template-footer button{flex-shrink:0}
#templatePreviewStage{height:auto;aspect-ratio:16/9;padding:0;overflow:hidden}
#templatePreviewBackdrop [hidden]{display:none!important}
#templates .template-toolbar{flex-wrap:wrap}
#templates .template-ownership-tabs{padding:0;background:transparent;border:0;border-radius:0;gap:24px}
#templates .template-ownership-tabs .segment{position:relative;padding:12px 2px;border:0;border-radius:0;background:transparent;color:#858195;box-shadow:none;font-size:17px;font-weight:600}
#templates .template-ownership-tabs .segment.active{color:#6d42d8;background:transparent}
#templates .template-ownership-tabs .segment.active:after{content:'';position:absolute;bottom:0;left:0;right:0;height:3px;border-radius:3px;background:#7950df}
#templates .template-ownership-tabs .segment span{font-size:12px;margin-left:6px;color:inherit}
#templates #templateSearch{width:230px!important;border-radius:8px;background:#faf9fc!important;border-color:#e8e4ef!important}
#templates .official-category-tabs{align-items:center;gap:8px;padding:14px 0 20px;margin:0;border-top:1px solid #eeeaf4}
#templates .official-category-tabs[hidden]{display:none}
#templates .official-category-tabs button{font-size:12px;border-color:transparent;border-radius:6px;padding:7px 12px;color:#787386;background:#f5f4f8}
#templates .official-category-tabs button.active{color:#7041cd;background:#eee7fc;border-color:transparent}
#templates .template-category-label{font-size:12px;color:#928d9e;margin-right:8px}
#templates .template-display-tags{display:flex;flex-wrap:wrap;gap:6px;min-width:0}
#templates .template-display-tags .tag{max-width:100%;font-size:11px;color:#827a91;background:#f5f3f8;line-height:1.5}
#templates .template-footer{align-items:flex-end}
#templates .template-generate-btn,#templatePreviewUse{color:#fff;background:#7950df;border:1px solid #7950df;border-radius:7px;padding:8px 13px}
#templates .template-generate-btn:hover,#templatePreviewUse:hover{background:#683bcb;border-color:#683bcb}
#templates button:focus-visible,#templatePreviewUse:focus-visible{outline:2px solid #7950df;outline-offset:3px}
#templates .template-search-status{font-size:13px;color:#857b97;margin-top:18px}
@media(max-width:650px){#templates .template-ownership-tabs{gap:24px}#templates .template-ownership-tabs .segment{flex:1}#templates #templateSearch{width:100%!important}#templates .official-category-tabs{gap:6px}#templates .template-category-label{width:100%}}
#square .square-cover{display:block;width:100%;height:auto;aspect-ratio:16/9;padding:0;border:0;background:#f3f4f8;cursor:pointer}
#square .square-cover:after{display:none}
#square .square-cover>svg{display:block;width:100%;height:100%}
#square .square-card-title b{white-space:normal;line-height:1.5}
#square .square-card-footer,#square .square-card-actions{flex-wrap:wrap}
#square .square-results{margin:14px 0;font-size:12px;color:#72798b}
.square-preview-stage{aspect-ratio:16/9;background:#f3f4f8;overflow:hidden}
.square-preview-stage svg{display:block;width:100%;height:100%}
.square-preview-controls{display:flex;align-items:center;justify-content:center;gap:16px;margin-top:12px}
#squareTemplatePreview .modal{width:min(1000px,94vw);max-height:94vh;overflow:auto}
#squareTemplatePreview .square-preview-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:16px}
@media(max-width:1100px){#templates .template-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:650px){#templates .template-grid{grid-template-columns:1fr}#templates .template-toolbar .segmented{width:100%}}
.template-upload-dialog{width:min(540px,calc(100vw - 32px))}.template-upload-dialog>p{font-size:13px;line-height:1.7;color:#64748b}.template-upload-dialog form{display:grid;gap:18px}.template-upload-dialog label{display:grid;gap:8px;font-size:13px;color:#475569}.template-upload-dialog input{padding:12px;border:1px solid #dce2ee;border-radius:7px}.template-upload-dialog input[type=file]{background:#f8f7ff;border-style:dashed}.template-upload-dialog small{font-size:12px;line-height:1.6;color:#94a3b8}.template-upload-actions{display:flex;justify-content:flex-end;gap:10px}#userTemplateUploadStatus{font-size:13px;color:#5146d8;line-height:1.6;min-height:22px}
