.template-dialog { width: min(1000px, calc(100vw - 32px)); max-width: none; max-height: none; }
.template-card { display: flex; flex-direction: column; height: min(780px, calc(100dvh - 40px)); }
.template-card .modal-header { flex: 0 0 auto; }
.template-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 0; flex: 1; }
.template-sidebar { display: flex; flex-direction: column; gap: 12px; padding: 20px; min-height: 0; background: #f5f8f6; border-right: 1px solid var(--line); }
.template-sidebar > * { flex-shrink: 0; }
.template-list-count { margin: 0; font-size: 12px; color: var(--ink-muted); }
.template-list { overflow: auto; min-height: 0; flex: 1; }
.template-list-item { width: 100%; display: grid; gap: 6px; padding: 12px; margin-bottom: 8px; text-align: left; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.template-list-item:hover { background: #eaf2ee; }
.template-list-item[aria-current="true"] { background: white; border-color: #a5c9bc; box-shadow: 0 1px 3px #153d2f0a; }
.template-list-item strong { font-size: 14px; }
.template-list-item small { font-size: 12px; line-height: 1.5; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-empty { padding: 20px 4px; color: var(--ink-muted); font-size: 13px; line-height: 1.8; }
.template-editor { display: flex; flex-direction: column; overflow: auto; min-width: 0; padding: 22px 26px; }
.template-editor > * { flex-shrink: 0; }
.template-editor-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.template-editor-heading h3 { margin: 0; font-size: 17px; }
#template-save-state { font-size: 12px; color: var(--teal); }
.template-note { margin: 8px 0 0; color: var(--ink-muted); font-size: 12px; line-height: 1.7; }
.template-editor .field-label { margin-top: 16px; font-size: 13px; }
.template-editor .text-input, .template-sidebar .text-input { font-size: 14px; padding: 10px 12px; }
#template-prompt { flex: 1 0 180px; min-height: 180px; resize: vertical; font-family: inherit; font-size: 14px; line-height: 1.75; }
.template-actions, .template-actions > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.template-actions { position: sticky; bottom: -22px; z-index: 1; background: var(--surface); border-top: 1px solid var(--line); justify-content: space-between; padding: 12px 0 10px; margin-top: 16px; gap: 12px; }
.template-actions .button { font-size: 13px; min-height: 36px; padding: 8px 12px; }
.template-confirm, .template-feedback { padding: 12px; margin-top: 12px; border-radius: 8px; font-size: 13px; line-height: 1.7; }
.template-confirm { background: #fff5df; border: 1px solid #eed09c; }
.template-confirm p { margin: 0 0 10px; }
.template-feedback { background: #edf6f2; color: #19624d; }
.template-feedback.error { background: #fff0ed; color: #9b4034; }
.template-dialog :focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.template-column-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.template-column-actions .field-pick { margin: 0; }
@media (max-width: 720px) {
  .template-dialog { width: calc(100vw - 16px); }
  .template-card { height: calc(100dvh - 20px); }
  .template-layout { display: flex; flex-direction: column; overflow: auto; }
  .template-sidebar { padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-right: 0; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
  .template-sidebar > * { min-width: 0; }
  .template-list { grid-column: 1 / -1; max-height: 130px; }
  .template-editor { padding: 18px; flex: 0 0 auto; overflow: visible; }
  #template-prompt { min-height: 240px; }
  .template-actions { bottom: 0; }
}
