/* Template concept 09. Scoped to template screens; shared workout controls retain their existing styles. */
.af-templates{width:100%;min-width:0;max-width:1100px;margin:auto}
.af-templates .af-flat-heading{margin:20px 0 5px}
.af-templates .af-flat-heading h2{font-size:25px;line-height:1.15;letter-spacing:-.6px}
.af-template-create-button{display:grid;place-items:center;flex:0 0 40px;width:40px;height:40px;padding:0;border:1px solid #303236;border-radius:12px;background:#080808;color:var(--lime)}
.af-template-create-button svg{width:21px;height:21px}
.af-template-library-caption{font-size:11px;color:#858d9b;margin:0 0 18px}
.af-template-search{display:flex;align-items:center;gap:9px;height:41px;padding:0 12px;border:1px solid #303236;border-radius:13px;background:#080808;box-sizing:border-box}
.af-template-search svg{width:16px;height:16px;color:#858d9b}
.af-template-search input{min-width:0;flex:1;background:none;border:0;color:white;padding:0;font:inherit;font-size:12px;outline:none}
.af-template-filters{display:flex;gap:7px;width:100%;margin:10px 0 16px}
.af-template-filters button{flex:1 1 0;min-width:0;min-height:32px;padding:0 4px;border:1px solid #303236;border-radius:10px;color:#a0a6b0;background:#080808;font-size:11px}
.af-template-filters button.active{color:var(--lime);border-color:#678b2c;background:#0d1206}
.af-template-list{display:grid;grid-template-columns:1fr;gap:12px}
.af-template-tile{display:grid;grid-template-columns:112px minmax(0,1fr);align-items:stretch;width:100%;min-height:133px;padding:0;background:#0b0b0b;border:1px solid #303236;border-radius:16px;overflow:hidden;color:white;text-align:left;box-sizing:border-box}
.af-template-tile.active{border-color:#678b2c;background:#0d1206}
.af-template-tile[hidden]{display:none}
.af-template-tile>.trainer-template-cover{position:relative;display:block;overflow:hidden;width:112px;height:100%;min-height:131px;aspect-ratio:auto}
.af-template-card-text{min-width:0;padding:14px;display:flex;flex-direction:column;justify-content:center;gap:9px}
.af-template-card-text>b{font-size:13px;line-height:1.35;font-weight:700;overflow-wrap:anywhere}
.af-template-card-text>small{font-size:10px;color:#858d9b}
/* Template overview: concept 6, a two-column exercise catalogue. */
.af-template-detail{max-width:960px}
.af-template-detail-bar{display:grid;grid-template-columns:44px minmax(0,1fr) 44px;align-items:center;gap:6px;min-height:64px;margin:0 0 15px}
.af-template-detail-bar>h2{margin:0;font-size:17px;line-height:1.25;font-weight:600;text-align:center}
.af-template-back{display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:0;background:none;color:white}
.af-template-back svg{width:22px;height:22px}
.af-template-menu{position:relative;align-self:center}
.af-template-menu summary{list-style:none;width:44px;height:44px;display:grid;place-items:center;color:var(--lime);cursor:pointer;font-size:25px}
.af-template-menu summary::-webkit-details-marker{display:none}
.af-template-menu>div{position:absolute;top:44px;right:0;z-index:8;display:grid;min-width:200px;padding:5px;border:1px solid #303236;border-radius:13px;background:#111;box-shadow:0 10px 30px #0008}
.af-template-menu>div>button{min-height:44px;padding:10px;border:0;border-radius:9px;background:none;color:white;font:inherit;font-size:12px;text-align:left;white-space:nowrap}
.af-template-menu>div>button.is-danger{color:#ff4c39}
.af-template-identity{display:grid;grid-template-columns:70px minmax(0,1fr);gap:14px;align-items:center;margin:0 0 23px}
.af-template-cover-button{display:block;width:70px;height:84px;padding:0;overflow:hidden;border:1px solid #303236;border-radius:12px;background:#151515;color:#6f7784}
.af-template-cover-button>.trainer-template-cover{width:100%;height:100%;aspect-ratio:auto}
.af-template-cover-button .trainer-template-cover>i{gap:4px}
.af-template-cover-button .trainer-template-cover>i svg{width:19px;height:19px}
.af-template-cover-button .trainer-template-cover>i small{font-size:9px}
.af-template-identity>div>small{color:#8d95a3;font-size:11px}
.af-template-identity h1{margin:5px 0 7px;color:white;font-size:19px;line-height:1.23;letter-spacing:-.2px;font-weight:700;overflow-wrap:anywhere}
.af-template-identity p{margin:0;color:#8d95a3;font-size:11px}
.af-template-days{display:flex;gap:7px;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none;margin:0 0 20px;padding:1px}
.af-template-days>button{flex:1 0 84px;min-height:40px;padding:8px 10px;border:1px solid #303236;border-radius:13px;background:transparent;color:white;font-size:13px;font-weight:600;white-space:nowrap}
.af-template-days>button[aria-selected=true]{border-color:var(--lime);color:var(--lime)}
.af-template-exercises-title{display:flex;justify-content:space-between;font-size:14px;font-weight:600;margin:0 0 8px}
.af-template-exercises-title span{font-size:12px;color:#8d95a3;font-weight:400}
.af-template-exercise-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;align-items:stretch}
.af-template-exercise-grid>.trainer-template-exercise-row{min-width:0;margin:0;padding:0;border:0}
.af-template-exercise-grid .trainer-template-exercise-open{display:flex;flex-direction:column;align-items:stretch;gap:0;width:100%;height:100%;min-height:0;padding:0;overflow:hidden;border:1px solid #303236;border-radius:14px;background:#090a0a;color:white;text-align:left;box-sizing:border-box}
.af-template-exercise-grid .trainer-template-exercise-preview{position:relative;display:block!important;flex:none;width:100%!important;height:112px!important;border:0!important;border-radius:0!important;background:#fff;overflow:hidden}
.af-template-exercise-grid .trainer-template-exercise-preview>i{background:#fff}
.af-template-exercise-grid .trainer-template-exercise-preview img{width:100%;height:100%;object-fit:contain;background:#fff}
.af-template-exercise-copy{display:flex;flex:1;flex-direction:column;min-width:0;padding:10px 10px 12px}
.af-template-exercise-copy b{display:block;min-height:47px;margin:0 0 8px;color:white;white-space:normal;overflow-wrap:anywhere;font-size:12px;font-weight:600;line-height:1.3}
.af-template-exercise-copy small{display:block;margin-top:auto;color:#8d95a3;font-size:11px;line-height:1.4}
@media(min-width:800px){
 .af-template-identity{max-width:640px}
 .af-template-exercise-grid .trainer-template-exercise-preview{height:160px!important}
 .af-template-exercise-copy{padding:14px}
 .af-template-exercise-copy b{font-size:14px;min-height:38px}
 .af-template-exercise-copy small{font-size:12px}
}
.af-template-add-exercise{display:flex;align-items:center;justify-content:center;gap:7px;width:100%;min-height:42px;margin-top:16px;border:1px solid #678b2c;border-radius:13px;color:var(--lime);background:none;font-size:12px;font-weight:600}
.af-template-add-exercise svg{width:17px;height:17px}
.af-template-create.trainer-modal-backdrop,.af-template-picker.trainer-modal-backdrop{position:fixed;inset:0;padding:0;background:#000;overflow:auto;align-items:flex-start}
.af-template-create .trainer-workout-modal.af-form-sheet,.af-template-picker .trainer-template-picker{width:100%;max-width:850px;min-height:100%;max-height:none;margin:0 auto;padding:0 18px 30px;box-sizing:border-box;border:0;border-radius:0;background:#000;box-shadow:none;gap:16px}
.af-template-create .af-form-sheet-head,.af-template-picker .trainer-template-picker>header{position:relative;display:flex;align-items:center;justify-content:center;min-height:64px;margin:0;padding:0;background:#000}
.af-template-create .af-form-sheet-head h3,.af-template-picker .trainer-template-picker>header h3{font-size:17px!important;font-weight:600;margin:0;padding:0 44px}
.af-template-create .af-sheet-close,.af-template-picker header>button{position:absolute;left:0;right:auto;width:44px;height:44px;padding:10px;border:0;border-radius:0;background:none;color:white}
.af-template-create .af-sheet-close::before,.af-template-create .af-sheet-close::after{display:none}
.af-template-create .af-sheet-close svg,.af-template-picker header>button svg{width:21px;height:21px}
.af-template-create .chip-row-title{font-size:11px;font-weight:400;color:#858d9b}
.af-template-create .input,.af-template-create select{height:44px;min-height:44px;border-radius:13px;font-size:13px;padding:10px 12px}
.af-template-create .trainer-workout-days{display:flex;flex-direction:column;align-items:stretch;gap:8px}
.af-template-create .trainer-workout-stepper{height:44px;min-height:44px;padding:0;border-radius:13px}
.af-template-create .trainer-workout-stepper button{width:40px;height:40px;min-height:0;background:none;border-radius:0}
.af-template-create .trainer-workout-stepper input{font-size:18px}
.af-template-create .trainer-workout-option{min-height:55px;padding:10px;border-radius:14px;gap:12px}
.af-template-create .trainer-workout-option i{flex-basis:21px;height:21px}
.af-template-create .trainer-workout-option b{font-size:13px}
.af-template-create .trainer-workout-option small{font-size:10px}
.af-template-create .mini-nav{width:100%;align-self:stretch;margin-top:8px}
.af-template-create .mini-nav>.btn{box-shadow:none;min-height:44px;border-radius:13px;font-size:14px}
.af-template-picker .trainer-template-picker{max-width:1100px}
.af-template-picker .af-template-list{margin-top:16px}
.af-template-sheet{padding:0 18px 30px}
.af-template-sheet>header{min-height:64px;margin-bottom:16px}
.af-template-sheet>header button{left:0;right:auto}
.af-template-cover-preview .trainer-template-cover{position:relative;display:block;overflow:hidden;width:100%;height:200px;aspect-ratio:auto;border-radius:16px;box-sizing:border-box}
.af-template-cover-form{display:grid;gap:16px}
.af-template-error{color:#ff4c39;font-size:12px;margin:0}
.af-template-error:empty{display:none}
.af-template-primary{width:100%;min-height:44px;padding:10px;border:0;border-radius:13px;background:var(--lime);color:black;font-size:14px;font-weight:700}
.af-template-primary:disabled{opacity:.35}
.af-template-primary.is-danger{background:#ff4c39;color:white}
.af-template-confirm{display:grid;gap:16px}
.af-template-confirm>button[type=button]{min-height:44px;border:0;background:none;color:white}
.af-template-confirm p{font-size:13px}
.trainer-template-preview-modal .trainer-template-preview-sheet{max-width:850px!important;padding-left:18px!important;padding-right:18px!important;min-height:100%;overflow-y:auto;border:0!important;border-radius:0!important;background:#000!important;box-shadow:none!important}
.trainer-template-preview-sheet>header{min-height:64px}
.trainer-template-preview-sheet>header b{font-size:17px;font-weight:600}
@media(min-width:800px){.af-template-list{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* Full-screen forms keep their controls inside Safari's visible safe area. */
.af-template-create.trainer-modal-backdrop,.af-template-picker.trainer-modal-backdrop{height:100%;height:100dvh;max-height:100dvh;overflow-x:hidden;overscroll-behavior:contain;backdrop-filter:none;-webkit-backdrop-filter:none}
.af-template-create .trainer-workout-modal.af-form-sheet,.af-template-picker .trainer-template-picker{min-height:100%;padding-top:env(safe-area-inset-top);padding-bottom:max(24px,env(safe-area-inset-bottom))}
.af-template-create .af-form-sheet-head,.af-template-picker .trainer-template-picker>header{position:sticky;top:0;z-index:3;border-bottom:0;flex-shrink:0}
.af-template-create .trainer-template-cover-upload{column-gap:12px;row-gap:0}
.af-template-create .trainer-workout-option{align-items:center}
.af-template-create .trainer-workout-option>i{flex-shrink:0}
.af-template-create .trainer-workout-option>span{min-width:0}
.af-template-create .trainer-workout-stepper button{flex-basis:40px}
.af-template-create .mini-nav{bottom:0;padding-bottom:8px}
.af-template-create [data-template-save]:disabled{opacity:.45;cursor:wait}
.af-template-create .af-template-cancel{min-height:36px;padding:0;border:0;background:none;color:#fff;font-size:12px}
.af-template-create .af-template-cancel:disabled{opacity:.45}
.af-template-create .trainer-template-cover-upload:focus-within{outline:2px solid var(--lime);outline-offset:3px}
.af-template-create .trainer-template-cover-upload[aria-busy=true]{opacity:.6;pointer-events:none}




.af-template-sheet{padding-top:env(safe-area-inset-top);padding-bottom:max(24px,env(safe-area-inset-bottom))}
.af-template-sheet>header{position:sticky;top:0;z-index:3;background:#000}
.af-template-sheet>header button{display:grid;place-items:center;padding:0}
.af-template-sheet>header h2{padding:0 44px;text-align:center}
.af-template-cover-preview{min-width:0;overflow:hidden;border-radius:16px}
.af-template-list button,.af-template-filters button,.af-template-create button{touch-action:manipulation}
@media(max-width:799px){
 .af-templates .af-flat-heading h2{font-size:25px;white-space:normal;overflow-wrap:normal}
 .af-template-create input.input,.af-template-create select,.af-template-search input{font-size:16px}
 .af-template-create .trainer-workout-modal.af-form-sheet{gap:14px}
 .af-template-picker .trainer-template-picker{display:flex;flex-direction:column}
 .af-template-picker .af-template-list{width:100%}
}

.af-template-create{scroll-padding-top:80px;scroll-padding-bottom:80px}
.af-template-create input,.af-template-create select{scroll-margin-block:80px}

.af-template-remove-cover{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:44px;border:1px solid #ff4c394d;border-radius:13px;background:transparent;color:#ff4c39;font-family:inherit;font-size:13px;font-weight:600}.af-template-remove-cover svg{width:18px;height:18px}.af-template-remove-cover:disabled{opacity:.4}

.af-template-crop.avatar-crop-backdrop{background:#000;padding:env(safe-area-inset-top) 18px max(24px,env(safe-area-inset-bottom));overflow:auto;backdrop-filter:none;z-index:13000}.af-template-crop .avatar-crop-sheet{width:min(100%,600px);border:0;border-radius:0;box-shadow:none;background:#000;padding:24px 0}.af-template-crop .avatar-crop-handle,.af-template-crop .avatar-crop-mask{display:none}.af-template-crop .avatar-crop-viewport{border-radius:16px;width:min(340px,calc(100vw - 48px));box-shadow:0 0 0 1px #484c52}.af-template-crop .avatar-crop-head h2{font-size:22px}.af-template-crop .avatar-crop-save{border-radius:13px;background:var(--lime);color:#000;min-height:44px}.af-template-crop-hint{color:#8d95a3;font-size:12px;text-align:center}

.af-template-remove-cover[hidden]{display:none}

/* The preview shares workout information controls and trainer edit/delete buttons. */
.trainer-template-preview-sheet>.af-exercise-action-row{margin:20px 0 0}
.trainer-template-preview-sheet>footer.af-exercise-edit-delete{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:20px 0 0;padding:0}

.af-template-preview-title{font-size:23px!important;font-weight:700!important;line-height:1.25!important;margin:0 0 20px!important;text-align:left!important;white-space:normal!important;overflow-wrap:break-word}
.af-template-preview-layout{display:grid;gap:20px}
.af-template-preview-media-column,.af-template-preview-data-column{min-width:0}
.af-template-preview-media-column>.af-exercise-action-row{margin:20px 0 0}
.af-template-preview-data-column>.af-exercise-edit-delete{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:20px 0 0;padding:0}
.af-template-worksets .af-workset-heading nav button{color:var(--lime)}
.af-template-worksets .gain-positive{color:var(--lime)}
@media(min-width:1000px){.trainer-template-preview-modal .trainer-template-preview-sheet{max-width:1200px!important}.af-template-preview-layout{grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:start;gap:28px}.af-template-preview-title{max-width:850px;font-size:26px!important}}

.trainer-template-preview-sheet::before{display:none}
.af-template-preview-header>button{display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:0;background:none;color:white}
.af-template-preview-header>button svg{width:22px;height:22px}
