.templates-page{height:100%;min-height:0;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--border-color) transparent;padding:28px;background:var(--surface-secondary);color:var(--text-primary)}
.templates-heading,.templates-toolbar,.template-results>header{display:flex;align-items:center;justify-content:space-between;gap:18px;min-width:0}
.templates-heading h1{font-size:25px;line-height:1.2;margin:0 0 7px}.templates-heading p,.template-results header p{margin:0;color:var(--text-muted);font-size:13px}
.templates-toolbar label{display:grid;gap:6px;min-width:0;font-size:11px;color:var(--text-muted)}
.templates-toolbar select,.template-results select{max-width:100%;min-width:0;border:1px solid var(--border-color);background:var(--surface-primary);color:var(--text-primary);border-radius:10px;min-height:44px;padding:8px 12px}
.templates-tabs{display:flex;gap:8px;margin:24px 0;overflow-x:auto;scrollbar-width:thin}
.templates-tabs button{flex:0 0 auto;min-height:44px;border:1px solid var(--border-color);background:var(--surface-primary);color:var(--text-secondary);border-radius:10px;padding:10px 17px;font-weight:700}
.templates-tabs button.active{background:var(--brand-700);border-color:var(--brand-700);color:white}
.templates-workspace{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px;align-items:start}
.templates-list,.template-preview-card,.template-send-card,.template-results,.template-settings{background:var(--surface-primary);border:1px solid var(--border-color);border-radius:16px;min-width:0;overflow:hidden;box-shadow:var(--shadow-card)}
.templates-list>header{display:flex;align-items:center;justify-content:space-between;padding:20px;border-bottom:1px solid var(--border-color)}
.templates-page h2,.template-settings h2{font-size:18px;margin:0;line-height:1.3}.templates-list header>span{padding:3px 8px;border-radius:12px;background:var(--brand-100);color:var(--brand-700);font-size:12px}
.templates-list-items{max-height:60vh;overflow:auto;scrollbar-width:thin}.templates-list-items button{display:flex;flex-direction:column;gap:7px;text-align:left;width:100%;border:0;border-bottom:1px solid var(--border-soft);background:transparent;color:var(--text-primary);padding:18px;overflow-wrap:anywhere}
.templates-list-items button.selected{background:var(--brand-100);box-shadow:inset 3px 0 var(--brand-500)}.templates-list-items button:hover{background:var(--surface-tertiary)}
.templates-list-items strong{font-size:14px}.templates-list-items small{font-size:12px;color:var(--text-muted)}.templates-list-items button>span{font-size:10px;letter-spacing:.04em;color:var(--brand-700)}
.template-preview-card,.template-send-card{padding:22px}.template-preview-card>header{display:flex;justify-content:space-between;align-items:start;gap:8px;margin-bottom:18px}.template-preview-card header p{margin:6px 0 0;font-size:12px;color:var(--text-muted);overflow-wrap:anywhere}
.template-preview-channel{font-size:10px;letter-spacing:.06em;border-radius:12px;background:var(--brand-100);color:var(--brand-700);padding:5px 8px}.template-send-card header p{color:var(--text-muted);font-size:13px;line-height:1.5;margin:9px 0 20px}
.template-fields{display:grid;gap:17px}.template-fields label,.template-settings label{display:grid;gap:8px;font-size:13px;font-weight:650;min-width:0}.template-fields input,.template-fields textarea,.template-settings input{width:100%;min-width:0;min-height:44px;padding:11px 12px;border:1px solid var(--border-color);border-radius:9px;background:var(--surface-secondary);color:var(--text-primary);font:inherit;font-weight:400}
.template-fields textarea{resize:vertical;min-height:128px}.template-fields input:focus,.template-fields textarea:focus{outline:2px solid var(--brand-500);outline-offset:1px}.template-help{font-size:12px;line-height:1.6;color:var(--text-muted);margin:0}.template-send-button{min-height:46px;width:100%;justify-content:center}
.templates-page button:disabled{opacity:.55;cursor:not-allowed}.template-empty{margin:0;padding:22px;color:var(--text-muted);font-size:13px;line-height:1.5}
.templates-page .primary-button,.template-settings .primary-button{border:1px solid var(--brand-700);border-radius:10px;background:var(--brand-700);color:white;padding:12px 18px;font-weight:750;min-height:46px;cursor:pointer}.templates-page .secondary-button{border:1px solid var(--border-color);border-radius:10px;background:var(--surface-primary);color:var(--brand-700);padding:11px 16px;min-height:44px;font-weight:700;cursor:pointer}.templates-page button:focus-visible,.template-settings button:focus-visible{outline:2px solid var(--brand-500);outline-offset:3px}
.template-chat-preview{padding:24px 18px;min-height:220px;background-color:#eee8df;background-image:radial-gradient(#c8c1b650 .8px,transparent .8px);background-size:14px 14px;border-radius:12px;display:flex;align-items:flex-start;justify-content:center}
.template-message{width:100%;max-width:360px;min-width:0;position:relative;background:#fff;color:#111b21;border-radius:0 9px 9px 9px;box-shadow:0 1px 1px #0002;font-family:"Segoe UI",sans-serif;font-size:14px;line-height:1.45;padding:12px 12px 0;overflow-wrap:anywhere}
.template-message::before{content:"";position:absolute;left:-8px;top:0;border-top:10px solid #fff;border-left:8px solid transparent}.template-header{font-weight:700;margin-bottom:8px;white-space:pre-wrap}.template-body{white-space:pre-wrap}.template-footer{font-size:12px;color:#667781;margin-top:10px;white-space:pre-wrap}.template-message code{font-size:13px;color:inherit}
.template-message-time{text-align:right;font-size:10px;line-height:1;color:#667781;padding:7px 0 9px}.template-message-button{color:#00a5f4;text-align:center;border-top:1px solid #e9edef;padding:11px 8px;margin:0 -12px;line-height:1.3}.template-message-button span{margin-right:7px}.template-media{display:block;width:100%;max-height:220px;object-fit:contain;border-radius:6px;margin-bottom:10px}.template-media-placeholder{display:grid;place-content:center;gap:6px;text-align:center;background:#e9edef;color:#667781;min-height:130px;border-radius:6px;margin-bottom:10px}.template-media-placeholder span{font-size:36px}
html[data-theme="dark"] .template-chat-preview{background-color:#0b141a;background-image:radial-gradient(#23303b80 .8px,transparent .8px)}html[data-theme="dark"] .template-message{background:#202c33;color:#e9edef}html[data-theme="dark"] .template-message::before{border-top-color:#202c33}html[data-theme="dark"] .template-message-time,html[data-theme="dark"] .template-footer{color:#8696a0}html[data-theme="dark"] .template-message-button{border-top-color:#34424a}html[data-theme="dark"] .template-media-placeholder{background:#34424a;color:#aebac1}
.template-results{padding:22px;margin-top:22px}.template-batch-progress{display:flex;gap:20px;flex-wrap:wrap;margin:20px 0;font-size:13px}.template-batch-progress strong{color:var(--brand-700)}.template-result-list{display:grid;gap:8px;max-height:360px;overflow:auto;scrollbar-width:thin}.template-result-row{display:grid;grid-template-columns:180px 1fr;gap:5px 15px;padding:12px;border:1px solid var(--border-soft);border-radius:9px;font-size:13px;overflow-wrap:anywhere}.template-result-row small{grid-column:1/-1;color:var(--danger);font-size:12px}.template-result-row.accepted>span{color:var(--brand-700)}.template-result-row.failed>span{color:var(--danger)}
.template-settings{padding:24px;max-width:600px}.template-settings p{color:var(--text-muted);line-height:1.6}.template-settings label{max-width:260px;margin:20px 0}.templates-page~.blazored-toast-container{max-height:85dvh;overflow:auto}
body:has(.templates-page) .blazored-toast-container{max-height:calc(100dvh - 40px);overflow-y:auto;scrollbar-width:thin}
@media(min-width:901px) and (max-width:1250px){.templates-toolbar{max-width:45%}.template-preview-card,.template-send-card{padding:16px}.template-preview-card>header{flex-wrap:wrap}}
@media(max-width:900px){.templates-heading{align-items:stretch;flex-direction:column}.templates-workspace{grid-template-columns:minmax(0,1fr)}.templates-list-items{max-height:220px}.templates-toolbar{width:100%}.templates-toolbar label{flex:1}.template-results>header{align-items:stretch;flex-direction:column}.template-preview-card,.template-send-card{padding:20px}.template-chat-preview{min-height:180px}}
@media(max-width:767px){.templates-page{padding:18px 12px}.templates-heading h1{font-size:25px}.templates-tabs{gap:6px;margin:18px 0}.templates-tabs button{padding:10px 12px;font-size:12px}.templates-toolbar{gap:8px}.templates-toolbar select{width:100%;font-size:14px}.templates-toolbar button{padding:10px;font-size:12px}.templates-workspace{gap:14px}.template-fields input,.template-fields textarea,.template-settings input{font-size:16px}.template-preview-card,.template-send-card,.template-results{padding:16px}.template-result-row{grid-template-columns:minmax(0,1fr) auto}.template-batch-progress{gap:12px}.rail-nav{gap:2px;min-width:0}.rail-link{flex:1 1 0;min-width:0;width:auto}.rail-link small{font-size:8px;max-width:100%;overflow:hidden;text-overflow:ellipsis}.template-chat-preview{padding:20px 14px}}
@media(prefers-reduced-motion:no-preference){.templates-page{scroll-behavior:smooth}}
@media(max-width:767px){.app-shell:has(.templates-page){height:100dvh;grid-template-rows:minmax(0,1fr) calc(58px + env(safe-area-inset-bottom))}.app-shell:has(.templates-page) .app-rail{padding-bottom:calc(5px + env(safe-area-inset-bottom))}}

.template-preview-card>header>div{min-width:0}
@media(max-width:767px){
    .template-preview-card>header{flex-wrap:wrap}
    .template-preview-channel{flex-shrink:0}
}
