.template-dialog { width:min(980px,calc(100vw - 32px)); }
body.studio-webawesome #editor-start { height:min(560px,calc(100% - 40px)); max-height:calc(100% - 40px); overflow-y:auto; }
body.studio-webawesome .template-example-link.studio-button { margin-top:8px; }
body.studio-webawesome .template-example-link.studio-button::part(button) { padding:5px 0; border-color:transparent; background:transparent; color:var(--blue-dark); }
.template-shell { min-height:0; }
.template-body { padding:24px; }
.template-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; align-items:stretch; }
.template-choice { display:flex; flex-direction:column; align-items:stretch; width:100%; min-width:0; padding:0; overflow:hidden; border:1px solid var(--line,#dfe3db); border-radius:10px; background:var(--studio-surface,#fffefa); color:var(--ink,#252a28); text-align:left; }
.template-choice:hover:not(:disabled) { border-color:var(--studio-border-strong,#c2c9bf); }
.template-choice[aria-pressed="true"] { border-color:var(--blue,#4354e8); box-shadow:0 0 0 2px var(--blue-pale,#eef0ff); }
.template-preview { display:flex; align-items:center; justify-content:center; width:100%; aspect-ratio:4/3; overflow:hidden; padding:14px; background:#e9ede5; }
.template-preview-image { display:block; width:100%; height:100%; object-fit:contain; filter:drop-shadow(0 3px 5px #24322318); }
.template-preview-image[hidden],.template-preview-placeholder[hidden] { display:none!important; }
.template-preview-placeholder { display:block; max-width:200px; font-size:12px; line-height:1.7; color:var(--muted,#626b65); text-align:center; }
.template-card-copy { display:grid; position:relative; gap:8px; width:100%; min-width:0; padding:17px 36px 18px 16px; white-space:normal; }
.template-card-title { display:block; font-size:15px; font-weight:700; letter-spacing:-.025em; }
.template-card-meta { font-size:10px; color:var(--muted,#626b65); font-variant-numeric:tabular-nums; }
.template-card-description { font-size:12px; line-height:1.7; color:var(--muted,#626b65); }
.template-card-selected { position:absolute; top:17px; right:14px; display:none; color:var(--blue,#4354e8); font-size:17px; font-weight:700; }
.template-choice[aria-pressed="true"] .template-card-selected { display:block; }
.template-selection { margin:20px 0 10px; font-size:12px; font-weight:650; line-height:1.7; color:var(--ink,#252a28); }
.template-feedback { flex:1; min-width:0; }
.template-feedback .template-warning { margin:0; color:var(--muted,#626b65); font-size:11px; line-height:1.6; }
.template-feedback .project-status { margin:5px 0 0; font-size:11px; line-height:1.6; }
.template-feedback .project-status:empty { display:none; }
.template-footer { justify-content:flex-end; align-items:center; gap:12px; }
.template-footer>.project-button { flex-shrink:0; }
body.studio-webawesome .template-choice.studio-button { display:block; width:100%; height:auto; padding:0; border:0; background:transparent; box-shadow:none; }
/* WA's small control has a fixed height; template cards need their full content. */
body.studio-webawesome .template-choice.studio-button::part(button) { display:block; width:100%; height:100%; min-height:100%; padding:0; overflow:hidden; border:1px solid var(--line); border-radius:10px; background:var(--studio-surface); color:var(--ink); text-align:left; }
body.studio-webawesome .template-choice.studio-button::part(label) { display:block; width:100%; padding:0; white-space:normal; }
body.studio-webawesome .template-choice.studio-button:hover::part(button) { background:var(--studio-surface); border-color:var(--studio-border-strong); }
body.studio-webawesome .template-choice.studio-button[aria-pressed="true"]::part(button) { border-color:var(--blue); box-shadow:inset 0 0 0 1px var(--blue); }
body.studio-webawesome .template-choice.studio-button:focus-within::part(button) { outline-offset:3px; }
@media(max-width:850px) {
  .template-dialog { width:min(740px,calc(100vw - 24px)); }
  .template-body { padding:18px; }
  .template-grid { gap:10px; }
  .template-preview { padding:9px; }
  .template-card-copy { padding:14px 28px 15px 12px; }
  .template-card-title { font-size:13px; }
  .template-card-description { font-size:11px; }
}
@media(max-width:620px) {
  .template-grid { grid-template-columns:minmax(0,1fr); }
  .template-preview { aspect-ratio:16/9; }
  .template-footer { flex-wrap:wrap; }
  .template-footer .template-feedback { flex-basis:100%; }
}
@media(forced-colors:active) {
  .template-choice[aria-pressed="true"],body.studio-webawesome .template-choice.studio-button[aria-pressed="true"]::part(button) { border:2px solid Highlight; }
}
