/* A return marker never changes item geometry or keyboard focus. */
.crm-return-anchor { animation: crm-return-anchor 1.2s ease-out; }
@keyframes crm-return-anchor {
 from { box-shadow: inset 0 0 0 2px #568b6159; background-color: #e9f2e6; }
 to { box-shadow: inset 0 0 0 2px transparent; }
}
@media (prefers-reduced-motion: reduce) {
 .crm-return-anchor { animation-duration: 1ms; }
}

/* AndroidCrm is installed before page scripts; desktop/browser dialogs keep their sizing. */
html.crm-apk dialog[open].messenger-template-dialog {
 --crm-template-top-reserve: 0px;
 position: fixed;
 top: calc(var(--crm-visible-top) + var(--crm-template-top-reserve));
 bottom: calc(var(--crm-visible-bottom) + var(--crm-nav-reserve));
 left: var(--crm-visible-left);
 right: var(--crm-visible-right);
 width: var(--crm-visible-width);
 max-width: var(--crm-visible-width);
 height: max(0px, calc(var(--crm-visible-height) - var(--crm-template-top-reserve) - var(--crm-nav-reserve)));
 max-height: max(0px, calc(var(--crm-visible-height) - var(--crm-template-top-reserve) - var(--crm-nav-reserve)));
 margin: 0;
 padding: 14px;
 border-radius: 0;
 display: flex;
 flex-direction: column;
 overflow: hidden;
}
html.crm-apk .messenger-template-dialog .dialog-head { flex: 0 0 auto; margin-bottom: 12px; }
html.crm-apk .messenger-template-dialog form {
 display: flex;
 flex-direction: column;
 flex: 1 1 auto;
 min-height: 0;
 gap: 12px;
 overflow-y: auto;
 overscroll-behavior: contain;
}
html.crm-apk .messenger-template-dialog form .field { flex: 0 0 auto; margin: 0; }
html.crm-apk .messenger-template-dialog form .field:has(textarea) { display: flex; flex-direction: column; flex: 1 0 180px; }
html.crm-apk .messenger-template-dialog textarea { flex: 1 1 auto; height: auto !important; min-height: 140px; resize: none; overflow-y: auto; }
html.crm-apk .messenger-template-dialog .actions { flex: 0 0 auto; margin-top: auto; }
@media (max-width: 1000px) {
 html.crm-apk dialog[open].messenger-template-dialog { --crm-template-top-reserve: 54px; }
}
