
:root{font-family:Inter,system-ui,-apple-system,sans-serif;color:#111827;background:#f3f4f6}*{box-sizing:border-box}body{margin:0}header{min-height:64px;background:#111827;color:white;display:flex;align-items:center;justify-content:space-between;padding:0 5vw;gap:20px}.brand{color:white;text-decoration:none;font-weight:800}.user{display:flex;gap:12px;align-items:center;font-size:14px}main{max-width:1100px;margin:32px auto;padding:0 18px}.card{background:white;border-radius:18px;padding:24px;box-shadow:0 8px 30px rgba(0,0,0,.06)}.narrow{max-width:480px;margin:8vh auto}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:16px}.client{text-decoration:none;color:inherit;transition:.15s}.client:hover{transform:translateY(-2px)}h1{margin-top:0}label{display:flex;flex-direction:column;gap:7px;font-weight:600}input,select,textarea{font:inherit;padding:12px;border:1px solid #d1d5db;border-radius:10px}form{display:grid;gap:16px}button,.button{border:0;border-radius:10px;padding:12px 16px;background:#111827;color:white;font-weight:700;text-decoration:none;cursor:pointer}.linkbtn{padding:6px 8px;background:transparent}.title-row{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:18px}.muted{color:#6b7280}.flash{padding:12px 16px;background:#e0f2fe;border-radius:10px;margin-bottom:14px}.form-grid{grid-template-columns:repeat(2,1fr)}.wide{grid-column:1/-1}.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.stats div{background:#f9fafb;padding:14px;border-radius:12px}.stats span{display:block;color:#6b7280;font-size:12px}.stats strong{font-size:18px}.placeholder{margin-top:24px;padding:18px;border:1px dashed #9ca3af;border-radius:12px;color:#6b7280}@media(max-width:650px){header{padding:12px 18px;align-items:flex-start}.user{flex-direction:column;align-items:flex-end}.title-row{align-items:flex-start;flex-direction:column}.form-grid{grid-template-columns:1fr}.stats{grid-template-columns:repeat(2,1fr)}main{margin-top:20px}.card{padding:18px}}

.check-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:8px;margin:12px 0 22px}
.check{display:flex;flex-direction:row;align-items:center;gap:8px;background:#f9fafb;padding:10px;border-radius:10px;font-weight:500}
.check input{width:auto}
.program-list{display:grid;gap:8px}.program-row{display:flex;justify-content:space-between;gap:12px;padding:12px;background:#f9fafb;border-radius:10px;text-decoration:none;color:inherit}
.program-days{display:grid;gap:16px;margin-top:16px}.day-card{background:white;border-radius:18px;padding:20px;box-shadow:0 8px 30px rgba(0,0,0,.05)}
.program-block{border-top:1px solid #e5e7eb;padding:14px 0}.program-block:first-of-type{border-top:0}.program-block h3{margin:0 0 6px}.program-block p{margin:5px 0}.program-block ul{margin:8px 0 0}
.validation-ok{border-left:5px solid #10b981}.validation-error{border-left:5px solid #ef4444}.empty-day{color:#6b7280;padding:10px 0}
.secondary{background:#4b5563}

.structure-title{margin-top:28px}.structure-row{margin:12px 0}.card-subtle{background:#f9fafb;border:1px solid #e5e7eb;border-radius:14px;padding:16px}
.structure-row-head{display:flex;justify-content:space-between;align-items:end;gap:12px;margin-bottom:14px}.structure-row-head label{min-width:230px}
.danger-link{background:transparent;color:#b91c1c;padding:8px}.manual-picker{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;padding-top:4px}
.generate-button{margin-top:24px;width:100%;font-size:16px}.wide{grid-column:1/-1}

.actions{display:flex;gap:8px;flex-wrap:wrap}.profile-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;margin:18px 0}
.profile-box{background:#f9fafb;border-radius:12px;padding:14px}.profile-box h3{margin-top:0}.exercise-pref-list{display:grid;gap:8px;margin:14px 0 22px}
.exercise-pref-row{display:grid;grid-template-columns:minmax(220px,1fr) auto auto;gap:10px;align-items:center;padding:10px 12px;background:#f9fafb;border-radius:10px}
.exercise-pref-row small{display:block;color:#6b7280;margin-top:2px}.compact{padding:6px 8px}
@media(max-width:700px){.profile-grid{grid-template-columns:1fr}.exercise-pref-row{grid-template-columns:1fr}.actions{width:100%}}

.inline-form{display:inline}.inline-form button{white-space:nowrap}

.exercise-result{margin:14px 0;padding-top:10px;border-top:1px solid #e5e7eb}.exercise-result:first-child{border-top:0}
.set-row{display:grid;grid-template-columns:100px repeat(3,minmax(120px,1fr));gap:10px;align-items:end;padding:8px 0}
.set-row label{font-size:12px}.set-row input{padding:9px}.set-row.readonly{align-items:center;background:#f9fafb;border-radius:8px;padding:10px;margin:5px 0}
.workout-actions{display:flex;gap:12px;justify-content:flex-end;position:sticky;bottom:0;background:rgba(243,244,246,.95);padding:14px 0}.complete-button{background:#047857}
@media(max-width:700px){.set-row{grid-template-columns:1fr 1fr}.set-row>span:first-child{grid-column:1/-1;font-weight:700}.workout-actions{flex-direction:column}.workout-actions button{width:100%}}

.header-link{color:white;text-decoration:none;font-weight:700}.report-stats{margin-bottom:18px}
.report-list{display:grid;gap:10px}.report-row{display:grid;grid-template-columns:1.2fr 1fr 1fr;gap:14px;align-items:center;background:white;padding:14px 16px;border-radius:12px;text-decoration:none;color:inherit;box-shadow:0 6px 20px rgba(0,0,0,.04)}
.report-row div{display:flex;flex-direction:column;gap:3px}.report-row span{font-size:14px}.report-row small{color:#6b7280}.report-row:hover{transform:translateY(-1px)}
@media(max-width:700px){.report-row{grid-template-columns:1fr}.report-stats{grid-template-columns:repeat(2,1fr)}}

.progress-card{margin-top:16px}.progress-stats{margin:12px 0}.progress-history{display:grid;gap:6px}
.progress-history-row{display:grid;grid-template-columns:1.4fr 1fr 1fr;gap:10px;background:#f9fafb;border-radius:8px;padding:9px 10px;font-size:14px}
@media(max-width:700px){.progress-history-row{grid-template-columns:1fr}.progress-stats{grid-template-columns:repeat(2,1fr)}}

.weight-history-section{margin:24px 0}.weight-form{display:grid;grid-template-columns:1fr 1fr auto;gap:10px;align-items:end;margin-bottom:16px}
@media(max-width:700px){.weight-form{grid-template-columns:1fr}.weight-form button{width:100%}}

.client-dashboard{display:grid;gap:16px}
.client-welcome{padding-bottom:20px}
.client-summary-stats{margin-top:6px}
.client-next-workout{border-left:5px solid #047857}
.client-next-workout h2{margin-bottom:6px}
.eyebrow{text-transform:uppercase;letter-spacing:.08em;font-size:12px;font-weight:800;color:#6b7280;margin:0 0 8px}
@media(max-width:700px){
  .client-summary-stats{grid-template-columns:repeat(2,1fr)}
  .client-dashboard .button{width:100%;text-align:center}
}

.draft-editor{margin-top:18px}
.draft-exercise-list{display:grid;gap:10px}
.draft-exercise-row{display:grid;grid-template-columns:1fr 1.2fr 2fr;gap:14px;align-items:center;padding:12px;background:#f9fafb;border-radius:12px}
.draft-exercise-row>div{display:flex;flex-direction:column;gap:4px}
.draft-exercise-row small{color:#6b7280}
.draft-exercise-form{display:grid;grid-template-columns:1fr auto;gap:8px;align-items:end}
.draft-exercise-form label{min-width:0}
@media(max-width:760px){
  .draft-exercise-row{grid-template-columns:1fr}
  .draft-exercise-form{grid-template-columns:1fr}
}

.body-measurements-section{margin-top:16px}
.measurement-stats{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}
.measurement-stats small{display:block;margin-top:4px;color:#6b7280}
.measurement-form{margin-top:16px}
.measurement-form button{align-self:end}
.measurement-progress-card{margin-top:12px}
@media(max-width:700px){
  .measurement-stats{grid-template-columns:repeat(2,1fr)}
}

.library-list{display:grid;gap:9px}
.library-row{display:grid;grid-template-columns:1fr auto auto;gap:12px;align-items:center;padding:11px 12px;border:1px solid #e5e7eb;border-radius:12px}
.library-row>div{display:flex;flex-direction:column;gap:3px}
.library-row small{color:#6b7280}
.global-exercise-row{grid-template-columns:1fr auto}
.global-library-list{max-height:520px;overflow:auto}
@media(max-width:700px){
  .library-row{grid-template-columns:1fr}
  .global-exercise-row{grid-template-columns:1fr}
}

.archived-card{opacity:.96}
.archived-banner{margin:12px 0;border-style:dashed}
.archived-card form,.archived-banner form{margin:0}


/* =========================================================
   Stage 3.8 — Mobile-first athlete card
   ========================================================= */
.athlete-mobile-page{
  --athlete-blue:#2563eb;
  --athlete-blue-soft:#eff6ff;
  --athlete-green:#15803d;
  --athlete-green-soft:#ecfdf3;
  --athlete-border:#e5e7eb;
  --athlete-text:#111827;
  --athlete-muted:#6b7280;
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,1fr);
  gap:14px;
  max-width:960px;
  margin:0 auto;
}
.athlete-mobile-page>*{min-width:0}
.athlete-card,
.athlete-history-link,
.athlete-extra,
.athlete-alert{
  background:#fff;
  border:1px solid var(--athlete-border);
  border-radius:18px;
  box-shadow:0 8px 24px rgba(15,23,42,.05);
}
.athlete-card{padding:18px}
.athlete-hero{grid-column:1/-1;padding:20px}
.athlete-hero-top{display:flex;align-items:center;gap:16px}
.athlete-avatar{
  width:74px;height:74px;flex:0 0 74px;border-radius:50%;
  display:grid;place-items:center;
  background:linear-gradient(145deg,#dbeafe,#eef2ff);
  color:#1d4ed8;font-size:24px;font-weight:800;
}
.athlete-identity{min-width:0;flex:1}
.athlete-name-line{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.athlete-name-line h1{margin:0;font-size:25px;line-height:1.15}
.status-pill{
  display:inline-flex;align-items:center;width:max-content;
  border-radius:999px;padding:5px 9px;
  background:#f3f4f6;color:#4b5563;font-size:12px;font-weight:800;
}
.status-active{background:var(--athlete-green-soft);color:var(--athlete-green)}
.athlete-meta-grid{
  display:grid;grid-template-columns:repeat(4,minmax(0,1fr));
  gap:10px;margin-top:14px;
}
.athlete-meta-grid div{min-width:0}
.athlete-meta-grid span,
.athlete-extra-grid span{
  display:block;color:var(--athlete-muted);font-size:11px;margin-bottom:3px;
}
.athlete-meta-grid strong{font-size:14px;overflow-wrap:anywhere}
.athlete-hero-controls{
  display:flex;align-items:center;gap:8px;margin-top:16px;
  border-top:1px solid #f1f5f9;padding-top:14px;
}
.hero-progress,
.athlete-actions-menu>summary{
  border-radius:10px;padding:9px 12px;text-decoration:none;
  font-size:13px;font-weight:800;cursor:pointer;list-style:none;
}
.hero-progress{background:var(--athlete-blue);color:#fff}
.athlete-actions-menu{position:relative}
.athlete-actions-menu>summary{
  border:1px solid var(--athlete-border);background:#fff;color:var(--athlete-text)
}
.athlete-actions-menu>summary::-webkit-details-marker{display:none}
.action-menu-panel{
  position:absolute;z-index:20;top:44px;left:0;width:220px;
  display:grid;gap:4px;padding:8px;background:#fff;
  border:1px solid var(--athlete-border);border-radius:12px;
  box-shadow:0 16px 34px rgba(15,23,42,.14);
}
.action-menu-panel a,
.action-menu-panel button{
  display:block;width:100%;padding:10px 11px;border-radius:8px;
  color:#111827;background:#fff;text-align:left;text-decoration:none;
  font-size:13px;font-weight:700;
}
.action-menu-panel a:hover,.action-menu-panel button:hover{background:#f8fafc}
.action-menu-panel form{display:block;margin:0}
.athlete-section-head{
  display:flex;align-items:flex-start;justify-content:space-between;gap:10px;
  margin-bottom:13px;
}
.section-kicker{
  display:block;color:var(--athlete-muted);font-size:11px;
  font-weight:800;text-transform:uppercase;letter-spacing:.055em;margin-bottom:3px
}
.athlete-section-head h2{margin:0;font-size:18px;line-height:1.25}
.text-link,.mini-primary-link{
  color:var(--athlete-blue);text-decoration:none;font-size:12px;font-weight:800
}
.program-card-link{
  display:grid;grid-template-columns:46px minmax(0,1fr) auto;gap:12px;
  align-items:center;text-decoration:none;color:inherit;
  border-radius:12px;background:#f8fafc;padding:11px;
}
.program-icon,.history-link-icon{
  width:46px;height:46px;border-radius:12px;display:grid;place-items:center;
  background:var(--athlete-blue-soft);color:var(--athlete-blue);
  font-size:22px;font-weight:900
}
.program-card-main{min-width:0}
.program-card-main strong{display:block;font-size:16px;margin-bottom:3px}
.program-card-main span{display:block;color:var(--athlete-muted);font-size:12px}
.compact-progress{height:5px;background:#e5e7eb;border-radius:999px;margin-top:9px;overflow:hidden}
.compact-progress i{display:block;height:100%;border-radius:999px;background:var(--athlete-blue)}
.row-chevron{font-size:26px;color:#64748b;line-height:1}
.mini-primary-link{display:inline-flex;margin-top:10px}
.weight-chart-layout{
  display:grid;grid-template-columns:112px minmax(0,1fr);align-items:center;gap:12px;
}
.weight-current strong{display:block;font-size:28px;line-height:1.05}
.weight-current strong small{font-size:13px}
.weight-current span{display:block;margin-top:7px;font-size:13px;font-weight:800}
.delta-positive{color:var(--athlete-green)}
.delta-neutral{color:var(--athlete-muted)}
.weight-spark{min-width:0;color:var(--athlete-blue)}
.athlete-weight-chart{display:block;width:100%;height:auto;overflow:visible}
.athlete-weight-chart .chart-grid{stroke:#e5e7eb;stroke-width:1}
.athlete-weight-chart .chart-line{
  fill:none;stroke:currentColor;stroke-width:3;
  stroke-linecap:round;stroke-linejoin:round
}
.athlete-weight-chart circle{fill:#fff;stroke:currentColor;stroke-width:2}
.athlete-chart-empty{
  min-height:82px;border-radius:10px;background:#f8fafc;
  display:grid;place-items:center;padding:10px;color:var(--athlete-muted);font-size:12px
}
.measurement-strip{
  display:grid;grid-template-columns:repeat(4,minmax(0,1fr));
  border:1px solid #f1f5f9;border-radius:12px;overflow:hidden
}
.measurement-chip{padding:10px 9px;border-right:1px solid #f1f5f9}
.measurement-chip:last-child{border-right:0}
.measurement-chip span{display:block;color:var(--athlete-muted);font-size:11px;white-space:nowrap}
.measurement-chip strong{display:block;font-size:16px;margin-top:4px}
.measurement-chip small{display:block;color:var(--athlete-green);font-size:11px;margin-top:3px}
.inline-entry{margin-top:12px}
.inline-entry>summary{
  cursor:pointer;color:var(--athlete-blue);font-size:12px;font-weight:800;
  list-style:none;width:max-content
}
.inline-entry>summary::-webkit-details-marker{display:none}
.compact-entry-form,
.compact-measurement-form{
  margin-top:12px;padding-top:12px;border-top:1px solid #f1f5f9;
  display:grid;gap:10px
}
.compact-entry-form{grid-template-columns:1fr 1fr auto;align-items:end}
.compact-measurement-form{grid-template-columns:repeat(2,minmax(0,1fr))}
.compact-measurement-form button{grid-column:1/-1}
.compact-entry-form label,.compact-measurement-form label{font-size:12px}
.compact-entry-form input,.compact-measurement-form input{
  width:100%;padding:9px 10px;margin-top:4px
}
.compact-entry-form label>span,.compact-measurement-form label>span{
  display:block;border:1px solid #d1d5db;border-radius:10px;padding:9px 10px;margin-top:4px
}
.compact-entry-form label>span input,.compact-measurement-form label>span input{
  border:0;padding:0;margin:0
}
.quick-action-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.quick-action{
  min-width:0;border:1px solid var(--athlete-border);border-radius:12px;
  padding:11px 6px;display:flex;flex-direction:column;align-items:center;gap:6px;
  color:var(--athlete-text);text-decoration:none;text-align:center
}
.quick-action span{color:var(--athlete-blue);font-size:20px;line-height:1}
.quick-action strong{font-size:11px}
.athlete-note-card p{margin:0;color:#374151;line-height:1.45}
.athlete-history-link{
  display:grid;grid-template-columns:46px minmax(0,1fr) auto;align-items:center;gap:12px;
  padding:14px 16px;text-decoration:none;color:inherit
}
.athlete-history-link strong{display:block;font-size:15px}
.athlete-history-link small{display:block;color:var(--athlete-muted);font-size:11px;margin-top:2px}
.athlete-extra{grid-column:1/-1;padding:0;overflow:hidden}
.athlete-extra>summary{
  list-style:none;cursor:pointer;padding:15px 18px;font-weight:800;font-size:13px
}
.athlete-extra>summary::-webkit-details-marker{display:none}
.athlete-extra[open]>summary{border-bottom:1px solid #f1f5f9}
.athlete-extra-grid{
  display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;
  padding:16px 18px
}
.athlete-extra-grid>div{background:#f8fafc;border-radius:10px;padding:11px}
.athlete-extra-grid strong{font-size:13px;overflow-wrap:anywhere}
.athlete-extra h3{font-size:14px;margin:4px 18px 8px}
.extra-list{display:grid;gap:6px;padding:0 18px 16px}
.extra-row{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  background:#f8fafc;border-radius:9px;padding:9px 10px;
  color:inherit;text-decoration:none;font-size:12px
}
.extra-row small{color:var(--athlete-muted)}
.athlete-alert{
  grid-column:1/-1;padding:12px 14px;border-style:dashed;
  display:flex;gap:8px;align-items:center;flex-wrap:wrap
}
.athlete-alert span{color:var(--athlete-muted);font-size:12px}
.compact-copy{font-size:12px;margin:8px 0 0}

/* Dedicated workout-history page */
.history-page{max-width:780px;margin:0 auto}
.compact-title-row{margin-bottom:14px}
.history-workout-list{display:grid;gap:8px}
.history-workout-row{
  display:flex;align-items:center;justify-content:space-between;gap:14px;
  background:#fff;border:1px solid #e5e7eb;border-radius:14px;
  padding:13px 14px;text-decoration:none;color:inherit;
  box-shadow:0 5px 18px rgba(15,23,42,.04)
}
.history-workout-main{min-width:0}
.history-workout-main strong{display:block;font-size:14px}
.history-workout-main span{
  display:block;color:#6b7280;font-size:12px;margin-top:3px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis
}
.history-workout-meta{display:flex;align-items:flex-end;flex-direction:column;gap:5px;flex:0 0 auto}
.history-workout-meta small{color:#6b7280;font-size:11px}

/* Mobile is the primary layout for the athlete card. */
@media(max-width:700px){
  body{background:#f8fafc}
  header{min-height:54px;padding:9px 12px;align-items:center}
  header .brand{font-size:14px}
  header .user{font-size:11px;gap:5px;align-items:flex-end}
  header .user>span{display:none}
  header .header-link{font-size:11px}
  main{margin:12px auto;padding:0 10px 28px}
  .athlete-mobile-page{display:grid;grid-template-columns:1fr;gap:10px}
  .athlete-card{padding:13px;border-radius:15px}
  .athlete-hero{grid-column:auto;padding:14px}
  .athlete-hero-top{gap:11px;align-items:flex-start}
  .athlete-avatar{width:56px;height:56px;flex-basis:56px;font-size:18px}
  .athlete-name-line{gap:6px}
  .athlete-name-line h1{font-size:20px}
  .status-pill{font-size:10px;padding:4px 7px}
  .athlete-meta-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px 10px;margin-top:10px}
  .athlete-meta-grid span{font-size:10px}
  .athlete-meta-grid strong{font-size:12px}
  .athlete-hero-controls{margin-top:11px;padding-top:10px}
  .hero-progress,.athlete-actions-menu>summary{padding:8px 10px;font-size:11px}
  .action-menu-panel{left:auto;right:0;top:38px}
  .athlete-section-head{margin-bottom:9px}
  .section-kicker{font-size:9px}
  .athlete-section-head h2{font-size:15px}
  .program-card-link{grid-template-columns:40px minmax(0,1fr) auto;padding:9px;gap:9px}
  .program-icon,.history-link-icon{width:40px;height:40px;border-radius:10px;font-size:18px}
  .program-card-main strong{font-size:14px}
  .program-card-main span{font-size:10px}
  .compact-progress{margin-top:7px;height:4px}
  .weight-chart-layout{grid-template-columns:88px minmax(0,1fr);gap:7px}
  .weight-current strong{font-size:22px}
  .weight-current span{font-size:11px}
  .measurement-strip{grid-template-columns:repeat(4,minmax(0,1fr))}
  .measurement-chip{padding:8px 5px}
  .measurement-chip span{font-size:9px}
  .measurement-chip strong{font-size:13px}
  .measurement-chip small{font-size:9px}
  .quick-action-grid{gap:6px}
  .quick-action{padding:9px 3px;gap:5px}
  .quick-action span{font-size:17px}
  .quick-action strong{font-size:9px}
  .athlete-note-card p{font-size:12px}
  .athlete-history-link{padding:11px 12px;grid-template-columns:38px minmax(0,1fr) auto}
  .athlete-history-link strong{font-size:13px}
  .athlete-history-link small{font-size:9px}
  .athlete-extra{grid-column:auto}
  .athlete-extra>summary{padding:12px 13px;font-size:11px}
  .athlete-extra-grid{grid-template-columns:1fr 1fr;padding:12px 13px;gap:7px}
  .athlete-extra-grid>div{padding:8px}
  .athlete-extra-grid strong{font-size:11px}
  .athlete-extra h3{font-size:12px;margin:4px 13px 7px}
  .extra-list{padding:0 13px 12px}
  .compact-entry-form,.compact-measurement-form{grid-template-columns:1fr}
  .compact-measurement-form button{grid-column:auto}
  .compact-entry-form button{width:100%}
  .history-workout-row{padding:11px 12px}
  .history-workout-main strong{font-size:13px}
  .history-workout-main span{font-size:10px;max-width:210px}
}
@media(max-width:390px){
  .athlete-meta-grid{gap:6px}
  .measurement-chip:nth-child(4){display:none}
  .measurement-strip{grid-template-columns:repeat(3,minmax(0,1fr))}
  .quick-action strong{font-size:8.5px}
}

.athlete-card-caption{margin:0 0 10px;color:#6b7280;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.055em}

/* Stage 3.8.1 visible build marker */
.athlete-card-caption{display:flex;align-items:center;justify-content:space-between;gap:8px}
.athlete-card-caption b{display:inline-flex;padding:3px 7px;border-radius:999px;background:#eff6ff;color:#2563eb;font-size:10px;letter-spacing:0;text-transform:none}


/* =========================================================
   Stage 3.9.0 — Unified mobile-first product UI
   Applies the approved athlete-card visual language globally.
   ========================================================= */
:root{
  --fc-bg:#f6f8fb;
  --fc-surface:#ffffff;
  --fc-surface-soft:#f8fafc;
  --fc-text:#111827;
  --fc-muted:#6b7280;
  --fc-border:#e5e7eb;
  --fc-border-soft:#eef2f7;
  --fc-blue:#2563eb;
  --fc-blue-dark:#1d4ed8;
  --fc-blue-soft:#eff6ff;
  --fc-green:#15803d;
  --fc-green-soft:#ecfdf3;
  --fc-red:#b91c1c;
  --fc-red-soft:#fef2f2;
  --fc-radius:16px;
  --fc-shadow:0 7px 22px rgba(15,23,42,.045);
  color:var(--fc-text);
  background:var(--fc-bg);
}
html{background:var(--fc-bg);scroll-behavior:smooth}
body{
  margin:0;
  background:var(--fc-bg);
  color:var(--fc-text);
  min-height:100vh;
  -webkit-font-smoothing:antialiased;
}
a{color:var(--fc-blue)}
h1,h2,h3{color:var(--fc-text)}
h1{font-size:28px;line-height:1.15;letter-spacing:-.025em}
h2{font-size:19px;line-height:1.25}
h3{font-size:15px;line-height:1.3}
p{line-height:1.5}
.muted{color:var(--fc-muted)}

/* Global app shell */
.app-topbar{
  position:sticky;
  top:0;
  z-index:100;
  min-height:62px;
  padding:0;
  background:rgba(255,255,255,.96);
  color:var(--fc-text);
  border-bottom:1px solid var(--fc-border-soft);
  backdrop-filter:blur(14px);
}
.app-topbar-inner{
  width:min(1180px,100%);
  min-height:62px;
  margin:0 auto;
  padding:0 18px;
  display:flex;
  align-items:center;
  gap:18px;
}
.app-topbar .brand{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  gap:9px;
  color:var(--fc-text);
  text-decoration:none;
}
.brand-mark{
  width:34px;height:34px;border-radius:10px;
  display:grid;place-items:center;
  background:var(--fc-blue);
  color:#fff;
  font-size:11px;
  font-weight:900;
  letter-spacing:.02em;
}
.brand-copy{display:flex;flex-direction:column;line-height:1.05}
.brand-copy strong{font-size:14px}
.brand-copy small{font-size:9px;color:var(--fc-muted);margin-top:3px}
.app-icon{width:19px;height:19px;display:block}
.app-nav{
  display:flex;
  align-items:center;
  gap:3px;
  margin-left:auto;
}
.app-nav a{
  display:flex;
  align-items:center;
  gap:7px;
  padding:8px 10px;
  border-radius:10px;
  color:#64748b;
  text-decoration:none;
  font-size:12px;
  font-weight:750;
  transition:.15s ease;
}
.app-nav a:hover{background:var(--fc-surface-soft);color:var(--fc-text)}
.app-nav a.is-active{background:var(--fc-blue-soft);color:var(--fc-blue)}
.app-user{
  display:flex;
  align-items:center;
  gap:8px;
  padding-left:10px;
  border-left:1px solid var(--fc-border);
}
.app-user-avatar{
  width:32px;height:32px;border-radius:50%;
  display:grid;place-items:center;
  background:#e8eefc;
  color:var(--fc-blue);
  font-size:10px;font-weight:900;
}
.app-user-copy{display:flex;flex-direction:column;min-width:0;max-width:135px}
.app-user-copy strong{
  font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis
}
.app-user-copy small{
  font-size:9px;color:var(--fc-muted);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis
}
.app-user form{display:block;margin:0}
.app-logout{
  display:flex;align-items:center;gap:5px;
  padding:7px;
  background:transparent;
  color:#64748b;
  border-radius:9px;
  font-size:10px;
}
.app-logout:hover{background:#f8fafc;color:var(--fc-text)}
.app-logout .app-icon{width:17px;height:17px}
.app-main{
  width:min(1100px,100%);
  margin:22px auto 36px;
  padding:0 16px;
}
.mobile-nav{display:none}

/* Surfaces */
.card,.day-card,.card-subtle{
  background:var(--fc-surface);
  border:1px solid var(--fc-border);
  box-shadow:var(--fc-shadow);
}
.card{
  border-radius:var(--fc-radius);
  padding:18px;
}
.day-card{
  border-radius:var(--fc-radius);
  padding:17px;
}
.card-subtle{
  border-radius:13px;
  padding:13px;
  box-shadow:none;
  background:var(--fc-surface-soft);
}
.card + .card,
.card + section.card,
section.card + section.card{margin-top:12px}
.title-row{
  margin-bottom:14px;
  gap:12px;
}
.title-row h1{margin-bottom:4px}
.title-row p{margin:0}
.actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:7px;
  flex-wrap:wrap;
}

/* Buttons */
button,.button{
  min-height:40px;
  padding:9px 13px;
  border-radius:10px;
  background:var(--fc-blue);
  color:#fff;
  font-size:12px;
  font-weight:800;
  box-shadow:none;
  transition:.15s ease;
}
button:hover,.button:hover{background:var(--fc-blue-dark)}
.secondary{
  background:#fff;
  color:#374151;
  border:1px solid var(--fc-border);
}
.secondary:hover{background:var(--fc-surface-soft);color:var(--fc-text)}
.linkbtn,.app-logout{min-height:auto}
.danger-link{color:var(--fc-red)}
.generate-button,.complete-button{background:var(--fc-blue)}
.complete-button:hover,.generate-button:hover{background:var(--fc-blue-dark)}

/* Forms */
form{gap:13px}
label{
  gap:6px;
  font-size:12px;
  font-weight:750;
  color:#374151;
}
input,select,textarea{
  width:100%;
  min-height:42px;
  padding:10px 11px;
  border:1px solid #d7dce4;
  border-radius:10px;
  background:#fff;
  color:var(--fc-text);
  font-size:14px;
  outline:none;
  transition:border-color .15s,box-shadow .15s;
}
textarea{min-height:92px;resize:vertical}
input:focus,select:focus,textarea:focus{
  border-color:#93b4f8;
  box-shadow:0 0 0 3px rgba(37,99,235,.09);
}
.form-grid{gap:12px}
.check-grid{gap:7px;margin:10px 0 18px}
.check{
  min-height:42px;
  padding:9px 10px;
  border:1px solid var(--fc-border-soft);
  border-radius:10px;
  background:#fff;
  font-size:12px;
}
.check:has(input:checked){
  border-color:#bfdbfe;
  background:var(--fc-blue-soft);
}
.flash{
  padding:11px 13px;
  border:1px solid #dbeafe;
  border-radius:11px;
  background:var(--fc-blue-soft);
  color:#1e40af;
  font-size:12px;
}

/* Global stats */
.stats{gap:8px}
.stats div{
  min-width:0;
  padding:11px;
  border:1px solid var(--fc-border-soft);
  border-radius:11px;
  background:var(--fc-surface-soft);
}
.stats span{font-size:10px;color:var(--fc-muted)}
.stats strong{font-size:17px}

/* Primary athlete list */
.client-list-grid{
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}
.client-list-card{
  display:grid;
  grid-template-columns:46px minmax(0,1fr) auto auto;
  align-items:center;
  gap:11px;
  padding:13px;
  min-height:74px;
  transform:none;
}
.client-list-card:hover{
  transform:none;
  border-color:#cbd5e1;
  box-shadow:0 8px 24px rgba(15,23,42,.07);
}
.client-list-avatar{
  width:46px;height:46px;border-radius:50%;
  display:grid;place-items:center;
  background:var(--fc-blue-soft);
  color:var(--fc-blue);
  font-size:13px;
  font-weight:900;
}
.client-list-main{min-width:0}
.client-list-name{
  display:block;
  font-size:15px;
  font-weight:850;
  margin-bottom:4px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.client-list-meta{
  display:flex;
  align-items:center;
  gap:7px;
  flex-wrap:wrap;
  color:var(--fc-muted);
  font-size:10px;
}
.client-list-meta>span:not(:last-child)::after{
  content:"·";
  margin-left:7px;
  color:#cbd5e1;
}
.client-list-status{
  padding:4px 7px;
  border-radius:999px;
  background:var(--fc-green-soft);
  color:var(--fc-green);
  font-size:9px;
  font-weight:850;
}
.empty-state{text-align:center;padding:32px 18px}
.empty-state-icon{
  width:44px;height:44px;border-radius:13px;
  display:grid;place-items:center;margin:0 auto 10px;
  background:var(--fc-blue-soft);color:var(--fc-blue);
  font-size:24px
}
.empty-state h2{margin:0 0 5px}
.empty-state p{margin:0;color:var(--fc-muted)}

/* Reusable row/list visual language */
.program-list,.report-list,.library-list,.progress-history{gap:7px}
.program-row,.report-row,.library-row,.progress-history-row{
  border:1px solid var(--fc-border-soft);
  border-radius:11px;
  background:#fff;
  box-shadow:none;
}
.program-row{
  padding:11px 12px;
  align-items:center;
}
.program-row:hover,.report-row:hover{background:var(--fc-surface-soft);transform:none}
.program-row strong{font-size:13px}
.program-row span{font-size:11px;color:var(--fc-muted)}
.report-row{
  padding:12px 13px;
  box-shadow:none;
}
.report-row strong,.report-row span{font-size:12px}
.report-row small{font-size:10px}
.library-row{padding:10px 11px}
.library-row strong{font-size:12px}
.library-row small{font-size:10px}
.global-library-list{
  max-height:480px;
  border-radius:12px;
  padding-right:3px;
}

/* Program builder */
.structure-title{
  margin-top:22px;
  padding-top:18px;
  border-top:1px solid var(--fc-border-soft);
}
.structure-row{margin:9px 0}
.structure-row-head{margin-bottom:11px}
.manual-picker{gap:9px}
.format-panel{display:grid;gap:9px}
.format-day h3{margin-top:0}
.generate-button{
  min-height:46px;
  margin-top:18px;
  font-size:13px;
}
.program-days{gap:10px;margin-top:12px}
.program-block{padding:11px 0;border-color:var(--fc-border-soft)}
.program-block h3{font-size:14px}
.validation-ok{
  border-left:4px solid #22c55e;
  background:#fbfffc;
}
.validation-error{
  border-left:4px solid #ef4444;
  background:#fffdfd;
}

/* Draft editor */
.draft-editor{margin-top:12px}
.draft-exercise-list{gap:7px}
.draft-exercise-row{
  gap:10px;
  padding:10px;
  border:1px solid var(--fc-border-soft);
  border-radius:11px;
  background:#fff;
}
.draft-exercise-form{gap:7px}

/* Workout execution */
.exercise-result{
  margin:10px 0;
  padding-top:10px;
  border-color:var(--fc-border-soft);
}
.exercise-result h3{font-size:14px}
.set-row{
  gap:7px;
  padding:7px 0;
}
.set-row.readonly{
  background:var(--fc-surface-soft);
  border:1px solid var(--fc-border-soft);
  border-radius:9px;
  padding:9px;
}
.workout-actions{
  z-index:30;
  margin-top:10px;
  border-top:1px solid var(--fc-border);
  background:rgba(246,248,251,.94);
  backdrop-filter:blur(12px);
}

/* Progress */
.progress-card{margin-top:10px}
.progress-card h2{margin-bottom:4px}
.progress-stats{margin:9px 0}
.progress-history-row{
  padding:8px 10px;
  font-size:11px;
}
.measurement-progress-card{margin-top:9px}
.body-measurements-section{margin-top:10px}
.measurement-form{margin-top:12px}

/* Trainee diary */
.client-dashboard{gap:10px}
.client-welcome{padding:16px}
.client-next-workout{
  border-left:4px solid var(--fc-blue);
  padding:16px;
}
.eyebrow{
  font-size:9px;
  color:var(--fc-muted);
  letter-spacing:.07em;
}
.weight-history-section{margin:12px 0}
.weight-form{gap:8px}

/* Admin / archives */
.archived-card{opacity:1}
.archived-banner{
  background:#fffdf7;
  border-color:#f5d89b;
  border-style:solid;
}
.profile-grid{gap:9px;margin:12px 0}
.profile-box{
  padding:12px;
  border:1px solid var(--fc-border-soft);
  border-radius:11px;
  background:var(--fc-surface-soft);
}
.profile-box h3{font-size:12px;margin-bottom:6px}
.profile-box p{font-size:12px;margin:0}

/* Auth */
.app-public .app-topbar-inner{justify-content:center}
.app-public .brand-mark{width:38px;height:38px}
.app-public .app-main{max-width:520px}
.app-public .narrow{margin:7vh auto}
.app-public .card{padding:22px}

/* Fixed mobile navigation */
.mobile-nav{
  position:fixed;
  left:50%;
  bottom:max(8px,env(safe-area-inset-bottom));
  transform:translateX(-50%);
  z-index:110;
  width:min(calc(100% - 18px),520px);
  height:62px;
  padding:5px;
  display:none;
  grid-template-columns:repeat(auto-fit,minmax(64px,1fr));
  gap:3px;
  border:1px solid rgba(226,232,240,.95);
  border-radius:18px;
  background:rgba(255,255,255,.96);
  box-shadow:0 12px 35px rgba(15,23,42,.13);
  backdrop-filter:blur(16px);
}
.mobile-nav a{
  min-width:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:3px;
  border-radius:12px;
  color:#94a3b8;
  text-decoration:none;
  font-size:8.5px;
  font-weight:800;
}
.mobile-nav a .app-icon{width:20px;height:20px}
.mobile-nav a.is-active{background:var(--fc-blue-soft);color:var(--fc-blue)}

/* Tablet */
@media(max-width:860px){
  .app-nav a span{display:none}
  .app-nav a{padding:8px}
  .app-user-copy{display:none}
  .client-list-grid{grid-template-columns:1fr}
}

/* Mobile */
@media(max-width:700px){
  h1{font-size:21px}
  h2{font-size:16px}
  .app-topbar{min-height:52px}
  .app-topbar-inner{
    min-height:52px;
    padding:0 11px;
    gap:8px;
  }
  .brand-mark{width:30px;height:30px;border-radius:9px;font-size:9px}
  .brand-copy strong{font-size:12px}
  .brand-copy small{font-size:8px}
  .app-nav{display:none}
  .app-user{
    margin-left:auto;
    padding-left:0;
    border-left:0;
  }
  .app-user-avatar{width:29px;height:29px}
  .app-logout{padding:5px}
  .app-logout span{display:none}
  .has-mobile-nav .mobile-nav{display:grid}
  .has-mobile-nav .app-main{
    padding-bottom:84px;
  }
  .app-main{
    margin:10px auto 22px;
    padding-left:9px;
    padding-right:9px;
  }
  .card,.day-card{border-radius:14px;padding:13px}
  .title-row{
    flex-direction:column;
    align-items:stretch;
    margin-bottom:10px;
  }
  .title-row .actions{
    width:100%;
    justify-content:flex-start;
    flex-wrap:nowrap;
    overflow-x:auto;
    padding-bottom:2px;
    scrollbar-width:none;
  }
  .title-row .actions::-webkit-scrollbar{display:none}
  .title-row .actions .button,
  .title-row .actions button{
    flex:0 0 auto;
    width:auto;
    min-height:36px;
    padding:8px 10px;
    font-size:10px;
  }
  .form-grid{grid-template-columns:1fr}
  input,select,textarea{font-size:16px}
  button,.button{min-height:40px}
  .stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  .stats div{padding:9px}
  .stats strong{font-size:15px}
  .client-list-grid{gap:7px}
  .client-list-card{
    grid-template-columns:40px minmax(0,1fr) auto;
    gap:9px;
    min-height:64px;
    padding:10px;
  }
  .client-list-avatar{width:40px;height:40px;font-size:11px}
  .client-list-name{font-size:13px}
  .client-list-meta{font-size:9px;gap:5px}
  .client-list-meta>span:not(:last-child)::after{margin-left:5px}
  .client-list-status{display:none}
  .client-list-card .row-chevron{font-size:22px}
  .program-row{padding:10px}
  .program-row strong{font-size:12px}
  .program-row span{font-size:10px}
  .report-row{grid-template-columns:1fr 1fr;gap:7px}
  .report-row>div:first-child{grid-column:1/-1}
  .library-row,.global-exercise-row{grid-template-columns:minmax(0,1fr) auto}
  .library-row form{width:auto}
  .library-row button{min-height:34px;padding:7px 9px;font-size:10px}
  .global-library-list{max-height:430px}
  .check-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
  .check{min-height:38px;padding:7px 8px;font-size:10px}
  .structure-row-head{
    align-items:stretch;
    flex-direction:column;
  }
  .structure-row-head label{min-width:0}
  .manual-picker{grid-template-columns:1fr}
  .draft-exercise-row{grid-template-columns:1fr}
  .set-row{grid-template-columns:1fr 1fr;gap:6px}
  .set-row>span:first-child{grid-column:1/-1}
  .set-row label{font-size:10px}
  .workout-actions{
    bottom:72px;
    padding:9px 0;
  }
  .workout-actions button{width:100%}
  .progress-history-row{grid-template-columns:1fr 1fr}
  .progress-history-row>span:first-child{grid-column:1/-1;font-weight:700}
  .weight-form{grid-template-columns:1fr}
  .measurement-stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  .profile-grid{grid-template-columns:1fr}
  .app-public .app-main{padding:0 13px}
  .app-public .card{padding:18px}
}

/* Small phones */
@media(max-width:390px){
  .check-grid{grid-template-columns:1fr}
  .report-row{grid-template-columns:1fr}
  .report-row>div:first-child{grid-column:auto}
  .client-list-meta span:last-child{display:none}
}


/* =========================================================
   Stage 3.10.0 — Telegram-inspired lightweight UI
   Not a clone: uses the same product principles — light lists,
   clear blue actions, thin separators and wallpaper-friendly diary.
   ========================================================= */
.telegram-ui{
  --tg-blue:#3390ec;
  --tg-blue-hover:#2b7fd3;
  --tg-blue-soft:#eaf4ff;
  --tg-bg:#eef2f5;
  --tg-surface:#ffffff;
  --tg-text:#17212b;
  --tg-muted:#708499;
  --tg-line:#e7ebef;
  --tg-green:#31a24c;
  --tg-danger:#df3f40;
  background:var(--tg-bg);
  color:var(--tg-text);
}
.telegram-ui .app-topbar{
  background:rgba(255,255,255,.97);
  border-bottom:1px solid var(--tg-line);
  box-shadow:0 1px 2px rgba(0,0,0,.025);
}
.telegram-ui .brand-mark{
  width:32px;height:32px;
  border-radius:50%;
  background:var(--tg-blue);
  font-size:9px;
}
.telegram-ui .brand-copy strong{font-weight:750}
.telegram-ui .app-nav a{
  border-radius:8px;
  color:#5f7285;
  font-weight:650;
}
.telegram-ui .app-nav a.is-active{
  background:transparent;
  color:var(--tg-blue);
}
.telegram-ui .app-user-avatar{
  background:#dff0ff;
  color:var(--tg-blue);
}
.telegram-ui .app-main{
  width:min(980px,100%);
}
.telegram-ui h1,.telegram-ui h2,.telegram-ui h3{color:var(--tg-text)}
.telegram-ui .muted{color:var(--tg-muted)}

/* Telegram-like grouped sections: almost no shadow, thin separators. */
.telegram-ui .card,
.telegram-ui .day-card,
.telegram-ui .athlete-card,
.telegram-ui .athlete-history-link,
.telegram-ui .athlete-extra{
  background:rgba(255,255,255,.97);
  border:0;
  border-radius:12px;
  box-shadow:0 1px 2px rgba(0,0,0,.045);
}
.telegram-ui .card-subtle{
  background:#f7f9fb;
  border:0;
  box-shadow:none;
  border-radius:10px;
}
.telegram-ui .card + .card,
.telegram-ui .card + section.card,
.telegram-ui section.card + section.card{
  margin-top:9px;
}
.telegram-ui .section-kicker,
.telegram-ui .eyebrow,
.telegram-ui .telegram-section-title{
  color:var(--tg-blue);
  text-transform:none;
  letter-spacing:0;
  font-size:11px;
  font-weight:750;
}
.telegram-ui .title-row h1{
  font-weight:750;
  letter-spacing:-.02em;
}
.telegram-ui button,
.telegram-ui .button{
  background:var(--tg-blue);
  border-radius:9px;
  font-weight:700;
}
.telegram-ui button:hover,
.telegram-ui .button:hover{background:var(--tg-blue-hover)}
.telegram-ui .secondary{
  color:var(--tg-blue);
  background:transparent;
  border:0;
}
.telegram-ui .secondary:hover{background:var(--tg-blue-soft);color:var(--tg-blue)}
.telegram-ui input,
.telegram-ui select,
.telegram-ui textarea{
  border:1px solid #dce3e9;
  border-radius:9px;
  background:#fff;
}
.telegram-ui input:focus,
.telegram-ui select:focus,
.telegram-ui textarea:focus{
  border-color:#8bc3f5;
  box-shadow:0 0 0 2px rgba(51,144,236,.10);
}

/* Lists become one grouped white surface like Telegram settings/chat lists. */
.telegram-ui .program-list,
.telegram-ui .report-list,
.telegram-ui .library-list,
.telegram-ui .history-workout-list{
  overflow:hidden;
  gap:0;
  border-radius:12px;
  background:#fff;
  box-shadow:0 1px 2px rgba(0,0,0,.035);
}
.telegram-ui .program-row,
.telegram-ui .report-row,
.telegram-ui .library-row,
.telegram-ui .history-workout-row{
  border:0;
  border-bottom:1px solid var(--tg-line);
  border-radius:0;
  background:#fff;
  box-shadow:none;
}
.telegram-ui .program-row:last-child,
.telegram-ui .report-row:last-child,
.telegram-ui .library-row:last-child,
.telegram-ui .history-workout-row:last-child{
  border-bottom:0;
}
.telegram-ui .program-row:hover,
.telegram-ui .report-row:hover,
.telegram-ui .library-row:hover,
.telegram-ui .history-workout-row:hover{
  background:#f6f9fb;
}
.telegram-ui .client-list-grid{
  grid-template-columns:1fr;
  gap:0;
  overflow:hidden;
  border-radius:12px;
  background:#fff;
  box-shadow:0 1px 2px rgba(0,0,0,.04);
}
.telegram-ui .client-list-card{
  min-height:70px;
  border:0;
  border-bottom:1px solid var(--tg-line);
  border-radius:0;
  box-shadow:none;
  background:#fff;
}
.telegram-ui .client-list-card:last-child{border-bottom:0}
.telegram-ui .client-list-avatar{
  background:linear-gradient(145deg,#65b8f3,#3390ec);
  color:#fff;
}
.telegram-ui .client-list-name{font-weight:720}
.telegram-ui .client-list-meta{color:var(--tg-muted)}
.telegram-ui .client-list-status{
  background:#eef8f0;
  color:var(--tg-green);
}

/* Stats are flatter and read as information cells instead of social-network cards. */
.telegram-ui .stats{
  overflow:hidden;
  border-radius:10px;
  background:#fff;
  gap:0;
}
.telegram-ui .stats div{
  border:0;
  border-right:1px solid var(--tg-line);
  border-radius:0;
  background:#fff;
}
.telegram-ui .stats div:last-child{border-right:0}
.telegram-ui .stats span{color:var(--tg-muted)}
.telegram-ui .stats strong{font-weight:720}

/* Athlete page */
.telegram-ui .athlete-mobile-page{gap:9px}
.telegram-ui .athlete-avatar{
  background:linear-gradient(145deg,#75c3f5,#3390ec);
  color:#fff;
}
.telegram-ui .status-active{
  color:var(--tg-green);
  background:#edf8ef;
}
.telegram-ui .hero-progress{
  background:transparent;
  color:var(--tg-blue);
  padding-left:0;
}
.telegram-ui .athlete-actions-menu>summary{
  border:0;
  color:var(--tg-blue);
  background:transparent;
}
.telegram-ui .action-menu-panel{
  border:1px solid var(--tg-line);
  border-radius:10px;
  box-shadow:0 7px 24px rgba(23,33,43,.12);
}
.telegram-ui .program-card-link{
  background:#f7f9fb;
  border-radius:10px;
}
.telegram-ui .program-icon,
.telegram-ui .history-link-icon{
  border-radius:50%;
  background:var(--tg-blue);
  color:#fff;
}
.telegram-ui .compact-progress{background:#dfe7ee}
.telegram-ui .compact-progress i{background:var(--tg-blue)}
.telegram-ui .text-link,
.telegram-ui .mini-primary-link{color:var(--tg-blue)}
.telegram-ui .measurement-strip{
  border:0;
  border-radius:10px;
  background:#f7f9fb;
}
.telegram-ui .measurement-chip{border-color:var(--tg-line)}
.telegram-ui .quick-action{
  border:0;
  border-radius:10px;
  background:#f5f8fa;
}
.telegram-ui .quick-action span{color:var(--tg-blue)}
.telegram-ui .athlete-history-link{
  color:var(--tg-text);
}
.telegram-ui .athlete-extra-grid>div,
.telegram-ui .extra-row{
  background:#f7f9fb;
}

/* Diary wallpaper — same custom background is shown to athlete and trainer. */
.client-wallpaper-shell{
  position:relative;
  isolation:isolate;
  margin:-4px;
  padding:10px;
  border-radius:16px;
  overflow:hidden;
  background:
    radial-gradient(circle at 18px 18px,rgba(51,144,236,.06) 1.4px,transparent 1.5px) 0 0/36px 36px,
    radial-gradient(circle at 0 0,rgba(51,144,236,.035) 1px,transparent 1.2px) 0 0/22px 22px,
    #dcecf7;
}
.client-wallpaper-shell.has-custom-wallpaper{
  background-image:
    linear-gradient(rgba(20,33,44,.10),rgba(20,33,44,.10)),
    var(--client-wallpaper);
  background-size:cover;
  background-position:center;
  background-attachment:fixed;
}
.client-wallpaper-shell::before{
  content:"";
  position:absolute;
  inset:0;
  z-index:-1;
  pointer-events:none;
  background:rgba(235,244,250,.15);
}
.client-wallpaper-shell.has-custom-wallpaper::before{
  background:rgba(235,244,250,.05);
}
.client-wallpaper-shell .card,
.client-wallpaper-shell .athlete-card,
.client-wallpaper-shell .athlete-history-link,
.client-wallpaper-shell .athlete-extra{
  background:rgba(255,255,255,.91);
  backdrop-filter:blur(9px);
}
.diary-background-settings{
  margin-top:9px;
}
.diary-background-settings p{margin:4px 0 12px}
.background-upload-form{
  grid-template-columns:minmax(0,1fr) auto;
  align-items:end;
}
.background-upload-form input[type=file]{
  min-height:42px;
  padding:7px;
  background:#f7f9fb;
}
.background-remove-form{
  display:inline-block;
  margin-top:6px;
}
.diary-background-settings>small{
  display:block;
  margin-top:7px;
}

/* Reports/progress: grouped and calmer */
.telegram-ui .progress-card{
  box-shadow:0 1px 2px rgba(0,0,0,.035);
}
.telegram-ui .progress-history{
  border-radius:10px;
  overflow:hidden;
  gap:0;
  background:#fff;
}
.telegram-ui .progress-history-row{
  border:0;
  border-bottom:1px solid var(--tg-line);
  border-radius:0;
}
.telegram-ui .progress-history-row:last-child{border-bottom:0}

/* Mobile: resembles Telegram list/settings density. */
@media(max-width:700px){
  .telegram-ui{
    background:#eef2f5;
  }
  .telegram-ui .app-topbar{
    min-height:50px;
  }
  .telegram-ui .app-topbar-inner{
    min-height:50px;
    padding:0 10px;
  }
  .telegram-ui .brand-copy strong{font-size:11px}
  .telegram-ui .brand-copy small{display:none}
  .telegram-ui .app-main{
    margin-top:7px;
    padding-left:7px;
    padding-right:7px;
  }
  .telegram-ui .card,
  .telegram-ui .day-card,
  .telegram-ui .athlete-card{
    border-radius:11px;
    padding:12px;
  }
  .telegram-ui .title-row{
    padding:0 4px;
  }
  .telegram-ui .title-row .actions{
    gap:2px;
  }
  .telegram-ui .title-row .actions .button,
  .telegram-ui .title-row .actions button{
    color:var(--tg-blue);
    background:transparent;
    border:0;
    padding:7px 8px;
  }
  .telegram-ui .client-list-card{
    min-height:64px;
    padding:9px 10px;
  }
  .telegram-ui .stats{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .telegram-ui .stats div{
    border-right:0;
    border-bottom:1px solid var(--tg-line);
  }
  .telegram-ui .stats div:nth-child(odd){border-right:1px solid var(--tg-line)}
  .telegram-ui .stats div:nth-last-child(-n+2){border-bottom:0}
  .telegram-ui .mobile-nav{
    bottom:0;
    width:100%;
    height:58px;
    padding:3px max(6px,env(safe-area-inset-left)) max(3px,env(safe-area-inset-bottom));
    border:0;
    border-top:1px solid var(--tg-line);
    border-radius:0;
    box-shadow:0 -1px 4px rgba(0,0,0,.035);
    background:rgba(255,255,255,.98);
  }
  .telegram-ui .mobile-nav a{
    border-radius:8px;
    color:#7d8b99;
  }
  .telegram-ui .mobile-nav a.is-active{
    color:var(--tg-blue);
    background:transparent;
  }
  .telegram-ui .mobile-nav a .app-icon{width:19px;height:19px}
  .telegram-ui .mobile-nav a span{font-size:8px;font-weight:650}
  .telegram-ui.has-mobile-nav .app-main{padding-bottom:66px}
  .client-wallpaper-shell{
    margin:-2px -3px;
    padding:7px;
    border-radius:13px;
    background-attachment:scroll;
  }
  .background-upload-form{
    grid-template-columns:1fr;
  }
  .background-upload-form button{width:100%}
}

@media(max-width:390px){
  .telegram-ui .stats div:nth-child(odd){border-right:1px solid var(--tg-line)}
  .client-wallpaper-shell.has-custom-wallpaper{
    background-position:center top;
  }
}


/* =========================================================
   Stage 3.11.0 — Client Personal Settings
   Theme / font / text size / density / motion / avatar / wallpaper
   ========================================================= */

/* Avatar surfaces */
.app-user-avatar-photo,
.client-list-avatar-photo,
.athlete-avatar-photo,
.diary-profile-avatar{
  overflow:hidden;
  padding:0;
}
.app-user-avatar-photo img,
.client-list-avatar-photo img,
.athlete-avatar-photo img,
.diary-profile-avatar img{
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
}
.athlete-avatar-photo{
  background:#dce8f2 !important;
}
.diary-profile-head{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}
.diary-profile-avatar{
  width:52px;
  height:52px;
  flex:0 0 52px;
  border-radius:50%;
  background:#dff0ff;
  color:#3390ec;
}
.diary-profile-avatar-placeholder{
  display:grid;
  place-items:center;
  font-size:14px;
  font-weight:800;
}
.personal-settings-tab{
  white-space:nowrap;
}

/* Settings page */
.personal-settings-page{
  max-width:680px;
  margin:0 auto;
}
.settings-section{
  padding:0 !important;
  overflow:hidden;
}
.settings-section>.telegram-section-title{
  padding:14px 16px 7px;
}
.settings-section>p.muted{
  padding:0 16px 12px;
  margin:0;
  font-size:12px;
}
.personal-preferences-form{
  gap:0;
}
.settings-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(150px,190px);
  gap:14px;
  align-items:center;
  min-height:64px;
  padding:10px 16px;
  border-top:1px solid var(--tg-line);
}
.settings-row>div,
.settings-toggle>span{
  min-width:0;
}
.settings-row strong,
.settings-toggle strong,
.settings-media-row strong{
  display:block;
  font-size:13px;
}
.settings-row small,
.settings-toggle small{
  display:block;
  margin-top:3px;
  color:var(--tg-muted);
  font-size:10px;
  line-height:1.35;
}
.settings-row select{
  min-height:38px;
  padding:8px 10px;
}
.settings-toggle{
  display:grid;
  grid-template-columns:24px minmax(0,1fr);
  gap:10px;
  align-items:center;
  padding:12px 16px;
  border-top:1px solid var(--tg-line);
  cursor:pointer;
}
.settings-toggle input{
  width:20px;
  height:20px;
  min-height:0;
  margin:0;
  accent-color:var(--tg-blue);
}
.personal-preferences-form>button{
  margin:12px 16px 15px;
  width:calc(100% - 32px);
}
.settings-media-row{
  display:flex;
  align-items:center;
  gap:14px;
  padding:10px 16px 14px;
}
.settings-media-row p{
  margin:4px 0 0;
  font-size:11px;
}
.settings-avatar-image,
.settings-avatar-placeholder{
  width:72px;
  height:72px;
  flex:0 0 72px;
  border-radius:50%;
}
.settings-avatar-image{
  display:block;
  object-fit:cover;
  background:#dce8f2;
}
.settings-avatar-placeholder{
  display:grid;
  place-items:center;
  background:linear-gradient(145deg,#75c3f5,#3390ec);
  color:#fff;
  font-size:12px;
  font-weight:800;
}
.settings-upload-form{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:8px;
  align-items:end;
  padding:0 16px 10px;
}
.settings-upload-form input[type=file]{
  min-height:42px;
  padding:7px;
  background:#f7f9fb;
}
.settings-remove-form{
  display:block;
  padding:0 16px 8px;
}
.settings-remove-form button{
  padding-left:0;
}
.settings-section>small.muted{
  display:block;
  padding:0 16px 14px;
  font-size:10px;
}

/* Font family */
.telegram-ui.font-system{
  font-family:Inter,system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
}
.telegram-ui.font-rounded{
  font-family:ui-rounded,"SF Pro Rounded","Segoe UI",system-ui,Arial,sans-serif;
}
.telegram-ui.font-classic{
  font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;
}
.telegram-ui.font-system button,
.telegram-ui.font-system input,
.telegram-ui.font-system select,
.telegram-ui.font-system textarea,
.telegram-ui.font-rounded button,
.telegram-ui.font-rounded input,
.telegram-ui.font-rounded select,
.telegram-ui.font-rounded textarea,
.telegram-ui.font-classic button,
.telegram-ui.font-classic input,
.telegram-ui.font-classic select,
.telegram-ui.font-classic textarea{
  font-family:inherit;
}

/* User-controlled text size. `zoom` scales the application content without
   requiring each individual historical component to be rewritten. */
.telegram-ui.font-size-small .app-main{zoom:.94}
.telegram-ui.font-size-large .app-main{zoom:1.08}

/* Density */
.telegram-ui.density-compact .client-dashboard{gap:7px}
.telegram-ui.density-compact .card,
.telegram-ui.density-compact .day-card,
.telegram-ui.density-compact .athlete-card{
  padding:10px;
}
.telegram-ui.density-compact .program-row,
.telegram-ui.density-compact .history-workout-row{
  padding-top:8px;
  padding-bottom:8px;
}
.telegram-ui.density-comfortable .client-dashboard{gap:13px}
.telegram-ui.density-comfortable .card,
.telegram-ui.density-comfortable .day-card,
.telegram-ui.density-comfortable .athlete-card{
  padding:16px;
}
.telegram-ui.density-comfortable .program-row,
.telegram-ui.density-comfortable .history-workout-row{
  padding-top:13px;
  padding-bottom:13px;
}

/* Motion preference */
.telegram-ui.reduce-motion *,
.telegram-ui.reduce-motion *::before,
.telegram-ui.reduce-motion *::after{
  animation-duration:.001ms !important;
  animation-iteration-count:1 !important;
  transition-duration:.001ms !important;
  scroll-behavior:auto !important;
}

/* Dark theme */
.telegram-ui.theme-dark{
  --tg-bg:#17212b;
  --tg-surface:#202b36;
  --tg-text:#f2f5f7;
  --tg-muted:#9aaab8;
  --tg-line:#2d3a46;
  --tg-blue-soft:#243a50;
  background:var(--tg-bg);
  color:var(--tg-text);
}
.telegram-ui.theme-dark .app-topbar{
  background:rgba(32,43,54,.98);
  border-color:var(--tg-line);
}
.telegram-ui.theme-dark .brand,
.telegram-ui.theme-dark .brand-copy strong,
.telegram-ui.theme-dark h1,
.telegram-ui.theme-dark h2,
.telegram-ui.theme-dark h3,
.telegram-ui.theme-dark .client-list-name,
.telegram-ui.theme-dark .program-row,
.telegram-ui.theme-dark .report-row,
.telegram-ui.theme-dark .library-row,
.telegram-ui.theme-dark .history-workout-row{
  color:var(--tg-text);
}
.telegram-ui.theme-dark .card,
.telegram-ui.theme-dark .day-card,
.telegram-ui.theme-dark .athlete-card,
.telegram-ui.theme-dark .athlete-history-link,
.telegram-ui.theme-dark .athlete-extra,
.telegram-ui.theme-dark .client-list-grid,
.telegram-ui.theme-dark .program-list,
.telegram-ui.theme-dark .report-list,
.telegram-ui.theme-dark .library-list,
.telegram-ui.theme-dark .history-workout-list,
.telegram-ui.theme-dark .stats,
.telegram-ui.theme-dark .progress-history{
  background:var(--tg-surface);
  color:var(--tg-text);
}
.telegram-ui.theme-dark .client-list-card,
.telegram-ui.theme-dark .program-row,
.telegram-ui.theme-dark .report-row,
.telegram-ui.theme-dark .library-row,
.telegram-ui.theme-dark .history-workout-row,
.telegram-ui.theme-dark .progress-history-row,
.telegram-ui.theme-dark .stats div{
  background:var(--tg-surface);
  border-color:var(--tg-line);
  color:var(--tg-text);
}
.telegram-ui.theme-dark .card-subtle,
.telegram-ui.theme-dark .program-card-link,
.telegram-ui.theme-dark .quick-action,
.telegram-ui.theme-dark .athlete-extra-grid>div,
.telegram-ui.theme-dark .extra-row,
.telegram-ui.theme-dark .set-row.readonly,
.telegram-ui.theme-dark .profile-box{
  background:#263440;
  color:var(--tg-text);
}
.telegram-ui.theme-dark input,
.telegram-ui.theme-dark select,
.telegram-ui.theme-dark textarea{
  background:#202b36;
  border-color:#3a4a58;
  color:#f2f5f7;
}
.telegram-ui.theme-dark input::placeholder,
.telegram-ui.theme-dark textarea::placeholder{
  color:#8393a0;
}
.telegram-ui.theme-dark .secondary{
  color:#6ab5f5;
}
.telegram-ui.theme-dark .app-user-avatar{
  background:#2c4358;
}
.telegram-ui.theme-dark .mobile-nav{
  background:rgba(32,43,54,.99);
  border-color:var(--tg-line);
}
.telegram-ui.theme-dark .mobile-nav a{color:#8c9ba8}
.telegram-ui.theme-dark .mobile-nav a.is-active{color:#64b5f6}
.telegram-ui.theme-dark .client-wallpaper-shell:not(.has-custom-wallpaper){
  background:
    radial-gradient(circle at 18px 18px,rgba(90,170,230,.07) 1.4px,transparent 1.5px) 0 0/36px 36px,
    #15202a;
}
.telegram-ui.theme-dark .client-wallpaper-shell .card,
.telegram-ui.theme-dark .client-wallpaper-shell .athlete-card,
.telegram-ui.theme-dark .client-wallpaper-shell .athlete-history-link,
.telegram-ui.theme-dark .client-wallpaper-shell .athlete-extra{
  background:rgba(32,43,54,.92);
}
.telegram-ui.theme-dark .client-wallpaper-shell::before{
  background:rgba(18,28,36,.10);
}
.telegram-ui.theme-dark .settings-upload-form input[type=file]{
  background:#263440;
}

/* System theme follows the device only for the trainee's personal interface. */
@media(prefers-color-scheme:dark){
  .telegram-ui.theme-system.app-client{
    --tg-bg:#17212b;
    --tg-surface:#202b36;
    --tg-text:#f2f5f7;
    --tg-muted:#9aaab8;
    --tg-line:#2d3a46;
    --tg-blue-soft:#243a50;
    background:var(--tg-bg);
    color:var(--tg-text);
  }
  .telegram-ui.theme-system.app-client .app-topbar{
    background:rgba(32,43,54,.98);
    border-color:var(--tg-line);
  }
  .telegram-ui.theme-system.app-client .brand,
  .telegram-ui.theme-system.app-client h1,
  .telegram-ui.theme-system.app-client h2,
  .telegram-ui.theme-system.app-client h3,
  .telegram-ui.theme-system.app-client .client-list-name,
  .telegram-ui.theme-system.app-client .program-row,
  .telegram-ui.theme-system.app-client .history-workout-row{
    color:var(--tg-text);
  }
  .telegram-ui.theme-system.app-client .card,
  .telegram-ui.theme-system.app-client .day-card,
  .telegram-ui.theme-system.app-client .program-list,
  .telegram-ui.theme-system.app-client .history-workout-list,
  .telegram-ui.theme-system.app-client .stats,
  .telegram-ui.theme-system.app-client .progress-history{
    background:var(--tg-surface);
    color:var(--tg-text);
  }
  .telegram-ui.theme-system.app-client .program-row,
  .telegram-ui.theme-system.app-client .history-workout-row,
  .telegram-ui.theme-system.app-client .progress-history-row,
  .telegram-ui.theme-system.app-client .stats div{
    background:var(--tg-surface);
    border-color:var(--tg-line);
    color:var(--tg-text);
  }
  .telegram-ui.theme-system.app-client .card-subtle,
  .telegram-ui.theme-system.app-client .quick-action,
  .telegram-ui.theme-system.app-client .set-row.readonly{
    background:#263440;
    color:var(--tg-text);
  }
  .telegram-ui.theme-system.app-client input,
  .telegram-ui.theme-system.app-client select,
  .telegram-ui.theme-system.app-client textarea{
    background:#202b36;
    border-color:#3a4a58;
    color:#f2f5f7;
  }
  .telegram-ui.theme-system.app-client .client-wallpaper-shell:not(.has-custom-wallpaper){
    background:#15202a;
  }
  .telegram-ui.theme-system.app-client .client-wallpaper-shell .card{
    background:rgba(32,43,54,.92);
  }
}

/* Mobile settings are intentionally a small dedicated tab, not a full admin page. */
@media(max-width:700px){
  .diary-profile-head{gap:9px}
  .diary-profile-avatar{
    width:44px;
    height:44px;
    flex-basis:44px;
  }
  .personal-settings-tab{
    order:-1;
  }
  .personal-settings-page .title-row{
    padding-left:3px;
    padding-right:3px;
  }
  .settings-row{
    grid-template-columns:minmax(0,1fr) 128px;
    gap:8px;
    min-height:58px;
    padding:9px 12px;
  }
  .settings-row strong{font-size:12px}
  .settings-row small{font-size:9px}
  .settings-section>.telegram-section-title{
    padding:12px 12px 6px;
  }
  .settings-section>p.muted{
    padding:0 12px 10px;
  }
  .settings-toggle{
    padding:10px 12px;
  }
  .personal-preferences-form>button{
    margin:10px 12px 12px;
    width:calc(100% - 24px);
  }
  .settings-media-row{
    padding:8px 12px 12px;
  }
  .settings-avatar-image,
  .settings-avatar-placeholder{
    width:62px;
    height:62px;
    flex-basis:62px;
  }
  .settings-upload-form{
    grid-template-columns:1fr;
    padding:0 12px 8px;
  }
  .settings-upload-form button{width:100%}
  .settings-remove-form{
    padding:0 12px 6px;
  }
  .settings-section>small.muted{
    padding:0 12px 12px;
  }
}


/* =========================================================
   Stage 3.11.1 — Global Client Personalization
   Client theme/font/density/wallpaper now covers every client page.
   ========================================================= */

/* A calm Telegram-like default wallpaper is present across every trainee screen. */
.telegram-ui.app-client.client-global-shell{
  min-height:100vh;
  background:
    radial-gradient(circle at 18px 18px,rgba(51,144,236,.060) 1.4px,transparent 1.5px) 0 0/36px 36px,
    radial-gradient(circle at 0 0,rgba(51,144,236,.035) 1px,transparent 1.2px) 0 0/22px 22px,
    #dcecf7;
  background-attachment:fixed;
}

/* When a trainee uploads an image, it becomes the background for ALL trainee pages:
   diary, workout, program, progress, history and personal settings. */
.telegram-ui.app-client.has-global-client-wallpaper{
  background-image:
    linear-gradient(rgba(20,33,44,.12),rgba(20,33,44,.12)),
    var(--client-global-wallpaper);
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
  background-attachment:fixed;
}

/* Navigation/tabs become translucent, so the wallpaper remains part of the UI. */
.telegram-ui.app-client.client-global-shell .app-topbar{
  background:rgba(255,255,255,.78);
  border-bottom:1px solid rgba(255,255,255,.52);
  box-shadow:0 1px 5px rgba(23,33,43,.08);
  backdrop-filter:blur(18px) saturate(135%);
  -webkit-backdrop-filter:blur(18px) saturate(135%);
}
.telegram-ui.app-client.client-global-shell .app-nav a{
  background:rgba(255,255,255,.18);
}
.telegram-ui.app-client.client-global-shell .app-nav a.is-active{
  background:rgba(255,255,255,.38);
}
.telegram-ui.app-client.client-global-shell .mobile-nav{
  background:rgba(255,255,255,.76);
  border-color:rgba(255,255,255,.50);
  backdrop-filter:blur(18px) saturate(135%);
  -webkit-backdrop-filter:blur(18px) saturate(135%);
}
.telegram-ui.app-client.client-global-shell .mobile-nav a{
  background:transparent;
}
.telegram-ui.app-client.client-global-shell .mobile-nav a.is-active{
  background:rgba(255,255,255,.30);
}

/* Every main client surface is translucent. */
.telegram-ui.app-client.client-global-shell .card,
.telegram-ui.app-client.client-global-shell .day-card,
.telegram-ui.app-client.client-global-shell .card-subtle,
.telegram-ui.app-client.client-global-shell .athlete-card,
.telegram-ui.app-client.client-global-shell .athlete-history-link,
.telegram-ui.app-client.client-global-shell .athlete-extra,
.telegram-ui.app-client.client-global-shell .program-list,
.telegram-ui.app-client.client-global-shell .report-list,
.telegram-ui.app-client.client-global-shell .library-list,
.telegram-ui.app-client.client-global-shell .history-workout-list,
.telegram-ui.app-client.client-global-shell .progress-history,
.telegram-ui.app-client.client-global-shell .stats{
  background:rgba(255,255,255,.83);
  backdrop-filter:blur(12px) saturate(120%);
  -webkit-backdrop-filter:blur(12px) saturate(120%);
  box-shadow:0 1px 4px rgba(23,33,43,.075);
}

/* Rows keep enough opacity for text readability while still showing the wallpaper. */
.telegram-ui.app-client.client-global-shell .program-row,
.telegram-ui.app-client.client-global-shell .report-row,
.telegram-ui.app-client.client-global-shell .library-row,
.telegram-ui.app-client.client-global-shell .history-workout-row,
.telegram-ui.app-client.client-global-shell .progress-history-row,
.telegram-ui.app-client.client-global-shell .stats div,
.telegram-ui.app-client.client-global-shell .set-row.readonly,
.telegram-ui.app-client.client-global-shell .profile-box,
.telegram-ui.app-client.client-global-shell .quick-action,
.telegram-ui.app-client.client-global-shell .program-card-link{
  background:rgba(255,255,255,.56);
  border-color:rgba(120,145,165,.18);
}
.telegram-ui.app-client.client-global-shell .program-row:hover,
.telegram-ui.app-client.client-global-shell .history-workout-row:hover{
  background:rgba(255,255,255,.72);
}

/* Forms also visually belong to the selected theme/background. */
.telegram-ui.app-client.client-global-shell input,
.telegram-ui.app-client.client-global-shell select,
.telegram-ui.app-client.client-global-shell textarea{
  background:rgba(255,255,255,.82);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
}
.telegram-ui.app-client.client-global-shell .secondary{
  background:rgba(255,255,255,.24);
}
.telegram-ui.app-client.client-global-shell .secondary:hover{
  background:rgba(255,255,255,.44);
}

/* The old local wallpaper wrapper is still used on trainer-facing athlete cards only.
   On trainee pages the global shell is authoritative. */
.telegram-ui.app-client.client-global-shell .client-wallpaper-shell{
  margin:0;
  padding:0;
  border-radius:0;
  overflow:visible;
  background:none;
}
.telegram-ui.app-client.client-global-shell .client-wallpaper-shell::before{
  display:none;
}

/* Dark theme keeps the same transparency instead of replacing the user's wallpaper. */
.telegram-ui.app-client.client-global-shell.theme-dark{
  background-color:#17212b;
}
.telegram-ui.app-client.client-global-shell.theme-dark:not(.has-global-client-wallpaper){
  background:
    radial-gradient(circle at 18px 18px,rgba(90,170,230,.065) 1.4px,transparent 1.5px) 0 0/36px 36px,
    radial-gradient(circle at 0 0,rgba(90,170,230,.035) 1px,transparent 1.2px) 0 0/22px 22px,
    #17212b;
}
.telegram-ui.app-client.client-global-shell.theme-dark .app-topbar,
.telegram-ui.app-client.client-global-shell.theme-dark .mobile-nav{
  background:rgba(32,43,54,.78);
  border-color:rgba(125,155,180,.15);
}
.telegram-ui.app-client.client-global-shell.theme-dark .card,
.telegram-ui.app-client.client-global-shell.theme-dark .day-card,
.telegram-ui.app-client.client-global-shell.theme-dark .card-subtle,
.telegram-ui.app-client.client-global-shell.theme-dark .program-list,
.telegram-ui.app-client.client-global-shell.theme-dark .history-workout-list,
.telegram-ui.app-client.client-global-shell.theme-dark .progress-history,
.telegram-ui.app-client.client-global-shell.theme-dark .stats{
  background:rgba(32,43,54,.82);
}
.telegram-ui.app-client.client-global-shell.theme-dark .program-row,
.telegram-ui.app-client.client-global-shell.theme-dark .history-workout-row,
.telegram-ui.app-client.client-global-shell.theme-dark .progress-history-row,
.telegram-ui.app-client.client-global-shell.theme-dark .stats div,
.telegram-ui.app-client.client-global-shell.theme-dark .set-row.readonly,
.telegram-ui.app-client.client-global-shell.theme-dark .profile-box,
.telegram-ui.app-client.client-global-shell.theme-dark .quick-action,
.telegram-ui.app-client.client-global-shell.theme-dark .program-card-link{
  background:rgba(38,52,64,.66);
  border-color:rgba(145,170,190,.13);
}
.telegram-ui.app-client.client-global-shell.theme-dark input,
.telegram-ui.app-client.client-global-shell.theme-dark select,
.telegram-ui.app-client.client-global-shell.theme-dark textarea{
  background:rgba(32,43,54,.84);
}

/* System-dark mirrors the same translucent treatment. */
@media(prefers-color-scheme:dark){
  .telegram-ui.app-client.client-global-shell.theme-system{
    background-color:#17212b;
  }
  .telegram-ui.app-client.client-global-shell.theme-system:not(.has-global-client-wallpaper){
    background:
      radial-gradient(circle at 18px 18px,rgba(90,170,230,.065) 1.4px,transparent 1.5px) 0 0/36px 36px,
      #17212b;
  }
  .telegram-ui.app-client.client-global-shell.theme-system .app-topbar{
    background:rgba(32,43,54,.78);
  }
  .telegram-ui.app-client.client-global-shell.theme-system .card,
  .telegram-ui.app-client.client-global-shell.theme-system .day-card,
  .telegram-ui.app-client.client-global-shell.theme-system .program-list,
  .telegram-ui.app-client.client-global-shell.theme-system .history-workout-list,
  .telegram-ui.app-client.client-global-shell.theme-system .progress-history,
  .telegram-ui.app-client.client-global-shell.theme-system .stats{
    background:rgba(32,43,54,.82);
  }
  .telegram-ui.app-client.client-global-shell.theme-system .program-row,
  .telegram-ui.app-client.client-global-shell.theme-system .history-workout-row,
  .telegram-ui.app-client.client-global-shell.theme-system .progress-history-row,
  .telegram-ui.app-client.client-global-shell.theme-system .stats div{
    background:rgba(38,52,64,.66);
  }
}

@media(max-width:700px){
  .telegram-ui.app-client.client-global-shell{
    background-attachment:scroll;
  }
  .telegram-ui.app-client.has-global-client-wallpaper{
    background-attachment:scroll;
    background-position:center top;
  }
  .telegram-ui.app-client.client-global-shell .app-main{
    margin-top:6px;
  }
  .telegram-ui.app-client.client-global-shell .card,
  .telegram-ui.app-client.client-global-shell .day-card{
    background:rgba(255,255,255,.80);
  }
  .telegram-ui.app-client.client-global-shell.theme-dark .card,
  .telegram-ui.app-client.client-global-shell.theme-dark .day-card{
    background:rgba(32,43,54,.80);
  }
}

/* =========================================================
   Stage 3.11.2 — Dark text contrast + adjustable transparency
   ========================================================= */

/* User-controlled glass strength. "low" = more opaque / easier reading,
   "high" = more transparent / stronger wallpaper presence. */
.telegram-ui.app-client.transparency-low{
  --client-surface-light:rgba(255,255,255,.94);
  --client-row-light:rgba(255,255,255,.86);
  --client-nav-light:rgba(255,255,255,.91);
  --client-field-light:rgba(255,255,255,.94);
  --client-surface-dark:rgba(32,43,54,.95);
  --client-row-dark:rgba(38,52,64,.90);
  --client-nav-dark:rgba(32,43,54,.94);
  --client-field-dark:rgba(32,43,54,.96);
  --client-blur:9px;
}
.telegram-ui.app-client.transparency-medium{
  --client-surface-light:rgba(255,255,255,.82);
  --client-row-light:rgba(255,255,255,.66);
  --client-nav-light:rgba(255,255,255,.78);
  --client-field-light:rgba(255,255,255,.86);
  --client-surface-dark:rgba(32,43,54,.84);
  --client-row-dark:rgba(38,52,64,.72);
  --client-nav-dark:rgba(32,43,54,.82);
  --client-field-dark:rgba(32,43,54,.88);
  --client-blur:14px;
}
.telegram-ui.app-client.transparency-high{
  --client-surface-light:rgba(255,255,255,.68);
  --client-row-light:rgba(255,255,255,.46);
  --client-nav-light:rgba(255,255,255,.65);
  --client-field-light:rgba(255,255,255,.74);
  --client-surface-dark:rgba(32,43,54,.70);
  --client-row-dark:rgba(38,52,64,.54);
  --client-nav-dark:rgba(32,43,54,.68);
  --client-field-dark:rgba(32,43,54,.76);
  --client-blur:18px;
}

/* Apply chosen transparency to every client surface. */
.telegram-ui.app-client.client-global-shell .app-topbar,
.telegram-ui.app-client.client-global-shell .mobile-nav{
  background:var(--client-nav-light,rgba(255,255,255,.78)) !important;
  backdrop-filter:blur(var(--client-blur,14px)) saturate(135%);
  -webkit-backdrop-filter:blur(var(--client-blur,14px)) saturate(135%);
}
.telegram-ui.app-client.client-global-shell .card,
.telegram-ui.app-client.client-global-shell .day-card,
.telegram-ui.app-client.client-global-shell .card-subtle,
.telegram-ui.app-client.client-global-shell .athlete-card,
.telegram-ui.app-client.client-global-shell .athlete-history-link,
.telegram-ui.app-client.client-global-shell .athlete-extra,
.telegram-ui.app-client.client-global-shell .program-list,
.telegram-ui.app-client.client-global-shell .report-list,
.telegram-ui.app-client.client-global-shell .library-list,
.telegram-ui.app-client.client-global-shell .history-workout-list,
.telegram-ui.app-client.client-global-shell .progress-history,
.telegram-ui.app-client.client-global-shell .stats,
.telegram-ui.app-client.client-global-shell .settings-section{
  background:var(--client-surface-light,rgba(255,255,255,.82)) !important;
  backdrop-filter:blur(var(--client-blur,14px)) saturate(122%);
  -webkit-backdrop-filter:blur(var(--client-blur,14px)) saturate(122%);
}
.telegram-ui.app-client.client-global-shell .program-row,
.telegram-ui.app-client.client-global-shell .report-row,
.telegram-ui.app-client.client-global-shell .library-row,
.telegram-ui.app-client.client-global-shell .history-workout-row,
.telegram-ui.app-client.client-global-shell .progress-history-row,
.telegram-ui.app-client.client-global-shell .stats div,
.telegram-ui.app-client.client-global-shell .set-row.readonly,
.telegram-ui.app-client.client-global-shell .profile-box,
.telegram-ui.app-client.client-global-shell .quick-action,
.telegram-ui.app-client.client-global-shell .program-card-link,
.telegram-ui.app-client.client-global-shell .extra-row{
  background:var(--client-row-light,rgba(255,255,255,.66)) !important;
}
.telegram-ui.app-client.client-global-shell input,
.telegram-ui.app-client.client-global-shell select,
.telegram-ui.app-client.client-global-shell textarea{
  background:var(--client-field-light,rgba(255,255,255,.86)) !important;
}

/* Dark theme: force ALL textual UI content to light values.
   This intentionally covers historical components that used hard-coded dark colors. */
.telegram-ui.app-client.theme-dark,
.telegram-ui.app-client.theme-dark .app-main,
.telegram-ui.app-client.theme-dark .app-topbar,
.telegram-ui.app-client.theme-dark .card,
.telegram-ui.app-client.theme-dark .day-card,
.telegram-ui.app-client.theme-dark .card-subtle,
.telegram-ui.app-client.theme-dark .program-list,
.telegram-ui.app-client.theme-dark .history-workout-list,
.telegram-ui.app-client.theme-dark .progress-history,
.telegram-ui.app-client.theme-dark .stats,
.telegram-ui.app-client.theme-dark .settings-section{
  color:#f3f6f8 !important;
}
.telegram-ui.app-client.theme-dark h1,
.telegram-ui.app-client.theme-dark h2,
.telegram-ui.app-client.theme-dark h3,
.telegram-ui.app-client.theme-dark h4,
.telegram-ui.app-client.theme-dark p,
.telegram-ui.app-client.theme-dark span,
.telegram-ui.app-client.theme-dark strong,
.telegram-ui.app-client.theme-dark small,
.telegram-ui.app-client.theme-dark label,
.telegram-ui.app-client.theme-dark li,
.telegram-ui.app-client.theme-dark summary,
.telegram-ui.app-client.theme-dark .program-row,
.telegram-ui.app-client.theme-dark .history-workout-row,
.telegram-ui.app-client.theme-dark .progress-history-row,
.telegram-ui.app-client.theme-dark .quick-action,
.telegram-ui.app-client.theme-dark .program-card-link,
.telegram-ui.app-client.theme-dark .extra-row,
.telegram-ui.app-client.theme-dark .set-row,
.telegram-ui.app-client.theme-dark .settings-row,
.telegram-ui.app-client.theme-dark .settings-toggle,
.telegram-ui.app-client.theme-dark .athlete-history-link{
  color:#f3f6f8 !important;
}
.telegram-ui.app-client.theme-dark .muted,
.telegram-ui.app-client.theme-dark .program-row span,
.telegram-ui.app-client.theme-dark .history-workout-main span,
.telegram-ui.app-client.theme-dark .history-workout-meta small,
.telegram-ui.app-client.theme-dark .settings-row small,
.telegram-ui.app-client.theme-dark .settings-toggle small,
.telegram-ui.app-client.theme-dark .client-list-meta,
.telegram-ui.app-client.theme-dark .weight-current span,
.telegram-ui.app-client.theme-dark .athlete-meta-grid span,
.telegram-ui.app-client.theme-dark .section-kicker:not(.telegram-section-title){
  color:#b6c4cf !important;
}
.telegram-ui.app-client.theme-dark a:not(.button):not(.quick-action):not(.program-row):not(.history-workout-row){
  color:#72baf5;
}
.telegram-ui.app-client.theme-dark .telegram-section-title,
.telegram-ui.app-client.theme-dark .eyebrow,
.telegram-ui.app-client.theme-dark .text-link,
.telegram-ui.app-client.theme-dark .mini-primary-link{
  color:#72baf5 !important;
}
.telegram-ui.app-client.theme-dark input,
.telegram-ui.app-client.theme-dark select,
.telegram-ui.app-client.theme-dark textarea,
.telegram-ui.app-client.theme-dark option{
  color:#f5f7f9 !important;
  border-color:rgba(169,190,207,.22) !important;
  background:var(--client-field-dark,rgba(32,43,54,.88)) !important;
}
.telegram-ui.app-client.theme-dark input::placeholder,
.telegram-ui.app-client.theme-dark textarea::placeholder{
  color:#93a5b3 !important;
}
.telegram-ui.app-client.theme-dark .secondary{
  color:#7bc0f8 !important;
  background:rgba(60,90,115,.18) !important;
}
.telegram-ui.app-client.theme-dark .status-pill{
  color:#dce7ef !important;
  background:rgba(93,116,135,.30) !important;
}
.telegram-ui.app-client.theme-dark .status-active{
  color:#7fdb99 !important;
  background:rgba(49,162,76,.16) !important;
}
.telegram-ui.app-client.theme-dark .app-topbar,
.telegram-ui.app-client.theme-dark .mobile-nav{
  background:var(--client-nav-dark,rgba(32,43,54,.82)) !important;
}
.telegram-ui.app-client.theme-dark .card,
.telegram-ui.app-client.theme-dark .day-card,
.telegram-ui.app-client.theme-dark .card-subtle,
.telegram-ui.app-client.theme-dark .program-list,
.telegram-ui.app-client.theme-dark .history-workout-list,
.telegram-ui.app-client.theme-dark .progress-history,
.telegram-ui.app-client.theme-dark .stats,
.telegram-ui.app-client.theme-dark .settings-section{
  background:var(--client-surface-dark,rgba(32,43,54,.84)) !important;
}
.telegram-ui.app-client.theme-dark .program-row,
.telegram-ui.app-client.theme-dark .report-row,
.telegram-ui.app-client.theme-dark .library-row,
.telegram-ui.app-client.theme-dark .history-workout-row,
.telegram-ui.app-client.theme-dark .progress-history-row,
.telegram-ui.app-client.theme-dark .stats div,
.telegram-ui.app-client.theme-dark .set-row.readonly,
.telegram-ui.app-client.theme-dark .profile-box,
.telegram-ui.app-client.theme-dark .quick-action,
.telegram-ui.app-client.theme-dark .program-card-link,
.telegram-ui.app-client.theme-dark .extra-row{
  background:var(--client-row-dark,rgba(38,52,64,.72)) !important;
  border-color:rgba(160,185,205,.12) !important;
}

/* Device dark mode uses the same text-contrast correction when theme=system. */
@media(prefers-color-scheme:dark){
  .telegram-ui.app-client.theme-system,
  .telegram-ui.app-client.theme-system .app-main,
  .telegram-ui.app-client.theme-system h1,
  .telegram-ui.app-client.theme-system h2,
  .telegram-ui.app-client.theme-system h3,
  .telegram-ui.app-client.theme-system p,
  .telegram-ui.app-client.theme-system span,
  .telegram-ui.app-client.theme-system strong,
  .telegram-ui.app-client.theme-system small,
  .telegram-ui.app-client.theme-system label,
  .telegram-ui.app-client.theme-system li,
  .telegram-ui.app-client.theme-system summary,
  .telegram-ui.app-client.theme-system .program-row,
  .telegram-ui.app-client.theme-system .history-workout-row,
  .telegram-ui.app-client.theme-system .progress-history-row,
  .telegram-ui.app-client.theme-system .quick-action,
  .telegram-ui.app-client.theme-system .settings-row{
    color:#f3f6f8 !important;
  }
  .telegram-ui.app-client.theme-system .muted,
  .telegram-ui.app-client.theme-system .program-row span,
  .telegram-ui.app-client.theme-system .settings-row small,
  .telegram-ui.app-client.theme-system .settings-toggle small{
    color:#b6c4cf !important;
  }
  .telegram-ui.app-client.theme-system .app-topbar,
  .telegram-ui.app-client.theme-system .mobile-nav{
    background:var(--client-nav-dark,rgba(32,43,54,.82)) !important;
  }
  .telegram-ui.app-client.theme-system .card,
  .telegram-ui.app-client.theme-system .day-card,
  .telegram-ui.app-client.theme-system .card-subtle,
  .telegram-ui.app-client.theme-system .program-list,
  .telegram-ui.app-client.theme-system .history-workout-list,
  .telegram-ui.app-client.theme-system .progress-history,
  .telegram-ui.app-client.theme-system .stats,
  .telegram-ui.app-client.theme-system .settings-section{
    background:var(--client-surface-dark,rgba(32,43,54,.84)) !important;
  }
  .telegram-ui.app-client.theme-system .program-row,
  .telegram-ui.app-client.theme-system .history-workout-row,
  .telegram-ui.app-client.theme-system .progress-history-row,
  .telegram-ui.app-client.theme-system .stats div,
  .telegram-ui.app-client.theme-system .set-row.readonly,
  .telegram-ui.app-client.theme-system .quick-action,
  .telegram-ui.app-client.theme-system .program-card-link{
    background:var(--client-row-dark,rgba(38,52,64,.72)) !important;
  }
  .telegram-ui.app-client.theme-system input,
  .telegram-ui.app-client.theme-system select,
  .telegram-ui.app-client.theme-system textarea,
  .telegram-ui.app-client.theme-system option{
    color:#f5f7f9 !important;
    background:var(--client-field-dark,rgba(32,43,54,.88)) !important;
  }
}

/* =========================================================
   Stage 3.11.3 — Client accent color customization
   ========================================================= */

/* Six curated accent palettes. They intentionally affect accents rather than
   recoloring the whole page, so warning/error semantics remain unchanged. */
.telegram-ui.app-client.accent-blue{
  --tg-blue:#3390ec;
  --tg-blue-hover:#277fcf;
  --tg-blue-soft:rgba(51,144,236,.14);
  --accent-start:#75c3f5;
  --accent-end:#3390ec;
}
.telegram-ui.app-client.accent-teal{
  --tg-blue:#18a6a1;
  --tg-blue-hover:#128985;
  --tg-blue-soft:rgba(24,166,161,.14);
  --accent-start:#6bd3ce;
  --accent-end:#18a6a1;
}
.telegram-ui.app-client.accent-green{
  --tg-blue:#42a66a;
  --tg-blue-hover:#348a57;
  --tg-blue-soft:rgba(66,166,106,.14);
  --accent-start:#7acb98;
  --accent-end:#42a66a;
}
.telegram-ui.app-client.accent-purple{
  --tg-blue:#8774e1;
  --tg-blue-hover:#725fc8;
  --tg-blue-soft:rgba(135,116,225,.15);
  --accent-start:#b0a2ee;
  --accent-end:#8774e1;
}
.telegram-ui.app-client.accent-orange{
  --tg-blue:#ee8b35;
  --tg-blue-hover:#d77520;
  --tg-blue-soft:rgba(238,139,53,.15);
  --accent-start:#f7b36e;
  --accent-end:#ee8b35;
}
.telegram-ui.app-client.accent-pink{
  --tg-blue:#d45b9a;
  --tg-blue-hover:#b94882;
  --tg-blue-soft:rgba(212,91,154,.15);
  --accent-start:#ea8abe;
  --accent-end:#d45b9a;
}

/* Bridge legacy blue variables to the selected client accent. */
.telegram-ui.app-client[class*="accent-"]{
  --fc-blue:var(--tg-blue);
  --fc-blue-dark:var(--tg-blue-hover);
  --fc-blue-soft:var(--tg-blue-soft);
  --athlete-blue:var(--tg-blue);
  --athlete-blue-soft:var(--tg-blue-soft);
  accent-color:var(--tg-blue);
}

/* Selected accent also colors generated avatar placeholders. Uploaded photos
   are never tinted. */
.telegram-ui.app-client[class*="accent-"] .app-user-avatar:not(.app-user-avatar-photo),
.telegram-ui.app-client[class*="accent-"] .diary-profile-avatar-placeholder,
.telegram-ui.app-client[class*="accent-"] .settings-avatar-placeholder,
.telegram-ui.app-client[class*="accent-"] .client-list-avatar:not(.client-list-avatar-photo),
.telegram-ui.app-client[class*="accent-"] .athlete-avatar:not(.athlete-avatar-photo){
  background:linear-gradient(145deg,var(--accent-start),var(--accent-end)) !important;
  color:#fff !important;
}

/* Make sure common historical link/action styles inherit the selected accent. */
.telegram-ui.app-client[class*="accent-"] a:not(.program-row):not(.history-workout-row):not(.client-list-card),
.telegram-ui.app-client[class*="accent-"] .text-link,
.telegram-ui.app-client[class*="accent-"] .mini-primary-link,
.telegram-ui.app-client[class*="accent-"] .hero-progress,
.telegram-ui.app-client[class*="accent-"] .quick-action span,
.telegram-ui.app-client[class*="accent-"] .section-kicker,
.telegram-ui.app-client[class*="accent-"] .eyebrow,
.telegram-ui.app-client[class*="accent-"] .telegram-section-title{
  color:var(--tg-blue);
}
.telegram-ui.app-client[class*="accent-"] button:not(.secondary),
.telegram-ui.app-client[class*="accent-"] .button:not(.secondary),
.telegram-ui.app-client[class*="accent-"] .compact-progress i,
.telegram-ui.app-client[class*="accent-"] .program-icon,
.telegram-ui.app-client[class*="accent-"] .history-link-icon{
  background-color:var(--tg-blue);
}
.telegram-ui.app-client[class*="accent-"] button:not(.secondary):hover,
.telegram-ui.app-client[class*="accent-"] .button:not(.secondary):hover{
  background-color:var(--tg-blue-hover);
}
.telegram-ui.app-client[class*="accent-"] .mobile-nav a.is-active,
.telegram-ui.app-client[class*="accent-"] .app-nav a.is-active{
  color:var(--tg-blue);
}

/* Accent selector inside Personal Settings. */
.settings-color-row{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(260px,330px);
  gap:14px;
  align-items:center;
  padding:11px 16px;
  border-top:1px solid var(--tg-line);
}
.settings-color-row>div:first-child strong{
  display:block;
  font-size:13px;
}
.settings-color-row>div:first-child small{
  display:block;
  margin-top:3px;
  color:var(--tg-muted);
  font-size:10px;
  line-height:1.35;
}
.settings-color-picker{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:6px;
}
.settings-color-option{
  position:relative;
  display:flex;
  align-items:center;
  gap:6px;
  min-width:0;
  padding:7px 8px;
  border:1px solid var(--tg-line);
  border-radius:9px;
  background:rgba(255,255,255,.28);
  cursor:pointer;
  font-size:10px;
  font-weight:650;
}
.settings-color-option input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}
.settings-color-option:has(input:checked){
  border-color:var(--tg-blue);
  box-shadow:0 0 0 2px var(--tg-blue-soft);
}
.settings-color-dot{
  width:16px;
  height:16px;
  flex:0 0 16px;
  border-radius:50%;
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.08);
}
.color-blue .settings-color-dot{background:#3390ec}
.color-teal .settings-color-dot{background:#18a6a1}
.color-green .settings-color-dot{background:#42a66a}
.color-purple .settings-color-dot{background:#8774e1}
.color-orange .settings-color-dot{background:#ee8b35}
.color-pink .settings-color-dot{background:#d45b9a}

.telegram-ui.app-client.theme-dark .settings-color-option{
  background:rgba(38,52,64,.62);
}
@media(prefers-color-scheme:dark){
  .telegram-ui.app-client.theme-system .settings-color-option{
    background:rgba(38,52,64,.62);
  }
}

@media(max-width:700px){
  .settings-color-row{
    grid-template-columns:1fr;
    gap:8px;
    padding:10px 12px;
  }
  .settings-color-picker{
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
  .settings-color-option{
    padding:7px 6px;
    font-size:9px;
  }
}

@media(max-width:390px){
  .settings-color-picker{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

/* Dark contrast rules from 3.11.2 stay authoritative for normal text, while
   interactive accents use the selected palette. */
.telegram-ui.app-client.theme-dark[class*="accent-"] .telegram-section-title,
.telegram-ui.app-client.theme-dark[class*="accent-"] .eyebrow,
.telegram-ui.app-client.theme-dark[class*="accent-"] .text-link,
.telegram-ui.app-client.theme-dark[class*="accent-"] .mini-primary-link,
.telegram-ui.app-client.theme-dark[class*="accent-"] .hero-progress,
.telegram-ui.app-client.theme-dark[class*="accent-"] .quick-action span,
.telegram-ui.app-client.theme-dark[class*="accent-"] .app-nav a.is-active,
.telegram-ui.app-client.theme-dark[class*="accent-"] .mobile-nav a.is-active,
.telegram-ui.app-client.theme-dark[class*="accent-"] .secondary{
  color:var(--tg-blue) !important;
}
@media(prefers-color-scheme:dark){
  .telegram-ui.app-client.theme-system[class*="accent-"] .telegram-section-title,
  .telegram-ui.app-client.theme-system[class*="accent-"] .eyebrow,
  .telegram-ui.app-client.theme-system[class*="accent-"] .text-link,
  .telegram-ui.app-client.theme-system[class*="accent-"] .mini-primary-link,
  .telegram-ui.app-client.theme-system[class*="accent-"] .quick-action span,
  .telegram-ui.app-client.theme-system[class*="accent-"] .app-nav a.is-active{
    color:var(--tg-blue) !important;
  }
}

/* =========================================================
   Stage 3.12.0 — Chat, trainer personalization and PWA identity
   ========================================================= */

.brand-app-icon{
  width:34px;height:34px;border-radius:10px;display:block;object-fit:cover;
  box-shadow:0 1px 4px rgba(23,33,43,.12);
}
.app-settings-link{
  width:32px;height:32px;display:grid;place-items:center;border-radius:50%;
  color:#708499;text-decoration:none;flex:0 0 auto;
}
.app-settings-link:hover{background:rgba(127,145,160,.12);color:var(--tg-blue)}
.app-settings-link .app-icon{width:18px;height:18px}

.nav-badge{
  display:inline-grid;place-items:center;min-width:17px;height:17px;padding:0 4px;
  margin-left:3px;border-radius:999px;background:#e64646;color:#fff!important;
  font-size:9px!important;line-height:1;font-weight:850;vertical-align:middle;
  box-shadow:0 0 0 2px rgba(255,255,255,.85);
}
.nav-badge[hidden]{display:none!important}
.mobile-nav .nav-badge{
  position:absolute;top:3px;left:calc(50% + 6px);margin:0;min-width:16px;height:16px;
  font-size:8px!important;box-shadow:0 0 0 2px rgba(255,255,255,.95);
}
.mobile-nav a{position:relative}

/* Trainer personalization mirrors the trainee's UI controls without sharing
   the trainee's wallpaper or private settings. */
.telegram-ui.trainer-personal-shell.transparency-low{
  --trainer-surface:rgba(255,255,255,.96);--trainer-row:rgba(255,255,255,.92);
  --trainer-nav:rgba(255,255,255,.96);--trainer-field:rgba(255,255,255,.98);--trainer-blur:8px;
}
.telegram-ui.trainer-personal-shell.transparency-medium{
  --trainer-surface:rgba(255,255,255,.88);--trainer-row:rgba(255,255,255,.78);
  --trainer-nav:rgba(255,255,255,.91);--trainer-field:rgba(255,255,255,.92);--trainer-blur:12px;
}
.telegram-ui.trainer-personal-shell.transparency-high{
  --trainer-surface:rgba(255,255,255,.76);--trainer-row:rgba(255,255,255,.62);
  --trainer-nav:rgba(255,255,255,.82);--trainer-field:rgba(255,255,255,.84);--trainer-blur:16px;
}
.telegram-ui.trainer-personal-shell .app-topbar,
.telegram-ui.trainer-personal-shell .mobile-nav{
  background:var(--trainer-nav,rgba(255,255,255,.91))!important;
  backdrop-filter:blur(var(--trainer-blur,12px)) saturate(125%);
  -webkit-backdrop-filter:blur(var(--trainer-blur,12px)) saturate(125%);
}
.telegram-ui.trainer-personal-shell .card,
.telegram-ui.trainer-personal-shell .day-card,
.telegram-ui.trainer-personal-shell .athlete-card,
.telegram-ui.trainer-personal-shell .athlete-history-link,
.telegram-ui.trainer-personal-shell .athlete-extra,
.telegram-ui.trainer-personal-shell .client-list-grid,
.telegram-ui.trainer-personal-shell .program-list,
.telegram-ui.trainer-personal-shell .report-list,
.telegram-ui.trainer-personal-shell .library-list,
.telegram-ui.trainer-personal-shell .history-workout-list,
.telegram-ui.trainer-personal-shell .stats,
.telegram-ui.trainer-personal-shell .settings-section,
.telegram-ui.trainer-personal-shell .chat-list,
.telegram-ui.trainer-personal-shell .chat-page{
  background:var(--trainer-surface,rgba(255,255,255,.88));
  backdrop-filter:blur(var(--trainer-blur,12px));
  -webkit-backdrop-filter:blur(var(--trainer-blur,12px));
}
.telegram-ui.trainer-personal-shell .client-list-card,
.telegram-ui.trainer-personal-shell .program-row,
.telegram-ui.trainer-personal-shell .report-row,
.telegram-ui.trainer-personal-shell .library-row,
.telegram-ui.trainer-personal-shell .history-workout-row,
.telegram-ui.trainer-personal-shell .stats div,
.telegram-ui.trainer-personal-shell .extra-row{
  background:var(--trainer-row,rgba(255,255,255,.78))!important;
}
.telegram-ui.trainer-personal-shell input,
.telegram-ui.trainer-personal-shell select,
.telegram-ui.trainer-personal-shell textarea{
  background:var(--trainer-field,rgba(255,255,255,.92))!important;
}

.telegram-ui.trainer-personal-shell.accent-blue{--tg-blue:#3390ec;--tg-blue-hover:#277fcf;--tg-blue-soft:rgba(51,144,236,.14);--accent-start:#75c3f5;--accent-end:#3390ec}
.telegram-ui.trainer-personal-shell.accent-teal{--tg-blue:#18a6a1;--tg-blue-hover:#128985;--tg-blue-soft:rgba(24,166,161,.14);--accent-start:#6bd3ce;--accent-end:#18a6a1}
.telegram-ui.trainer-personal-shell.accent-green{--tg-blue:#42a66a;--tg-blue-hover:#348a57;--tg-blue-soft:rgba(66,166,106,.14);--accent-start:#7acb98;--accent-end:#42a66a}
.telegram-ui.trainer-personal-shell.accent-purple{--tg-blue:#8774e1;--tg-blue-hover:#725fc8;--tg-blue-soft:rgba(135,116,225,.15);--accent-start:#b0a2ee;--accent-end:#8774e1}
.telegram-ui.trainer-personal-shell.accent-orange{--tg-blue:#ee8b35;--tg-blue-hover:#d77520;--tg-blue-soft:rgba(238,139,53,.15);--accent-start:#f7b36e;--accent-end:#ee8b35}
.telegram-ui.trainer-personal-shell.accent-pink{--tg-blue:#d45b9a;--tg-blue-hover:#b94882;--tg-blue-soft:rgba(212,91,154,.15);--accent-start:#ea8abe;--accent-end:#d45b9a}
.telegram-ui.trainer-personal-shell[class*="accent-"]{
  --fc-blue:var(--tg-blue);--fc-blue-dark:var(--tg-blue-hover);--fc-blue-soft:var(--tg-blue-soft);
  --athlete-blue:var(--tg-blue);--athlete-blue-soft:var(--tg-blue-soft);accent-color:var(--tg-blue);
}
.telegram-ui.trainer-personal-shell[class*="accent-"] button:not(.secondary),
.telegram-ui.trainer-personal-shell[class*="accent-"] .button:not(.secondary){background:var(--tg-blue)}
.telegram-ui.trainer-personal-shell[class*="accent-"] a:not(.client-list-card):not(.program-row):not(.history-workout-row){color:var(--tg-blue)}
.telegram-ui.trainer-personal-shell[class*="accent-"] .app-nav a.is-active,
.telegram-ui.trainer-personal-shell[class*="accent-"] .mobile-nav a.is-active{color:var(--tg-blue)}

/* Dark trainer theme gets explicit high-contrast surfaces. */
.telegram-ui.trainer-personal-shell.theme-dark{
  --trainer-surface:rgba(32,43,54,.88);--trainer-row:rgba(38,52,64,.80);
  --trainer-nav:rgba(32,43,54,.93);--trainer-field:rgba(32,43,54,.94);
  background:#17212b;color:#f3f6f8;
}
.telegram-ui.trainer-personal-shell.theme-dark h1,
.telegram-ui.trainer-personal-shell.theme-dark h2,
.telegram-ui.trainer-personal-shell.theme-dark h3,
.telegram-ui.trainer-personal-shell.theme-dark p,
.telegram-ui.trainer-personal-shell.theme-dark span,
.telegram-ui.trainer-personal-shell.theme-dark strong,
.telegram-ui.trainer-personal-shell.theme-dark small,
.telegram-ui.trainer-personal-shell.theme-dark label,
.telegram-ui.trainer-personal-shell.theme-dark summary,
.telegram-ui.trainer-personal-shell.theme-dark .client-list-card,
.telegram-ui.trainer-personal-shell.theme-dark .program-row,
.telegram-ui.trainer-personal-shell.theme-dark .report-row,
.telegram-ui.trainer-personal-shell.theme-dark .library-row,
.telegram-ui.trainer-personal-shell.theme-dark .history-workout-row{color:#f3f6f8!important}
.telegram-ui.trainer-personal-shell.theme-dark .muted,
.telegram-ui.trainer-personal-shell.theme-dark .client-list-meta,
.telegram-ui.trainer-personal-shell.theme-dark .program-row span,
.telegram-ui.trainer-personal-shell.theme-dark .settings-row small{color:#b6c4cf!important}
.telegram-ui.trainer-personal-shell.theme-dark input,
.telegram-ui.trainer-personal-shell.theme-dark select,
.telegram-ui.trainer-personal-shell.theme-dark textarea,
.telegram-ui.trainer-personal-shell.theme-dark option{color:#f5f7f9!important;border-color:rgba(169,190,207,.20)!important}

/* Chat list */
.chat-list-page{max-width:760px;margin:0 auto}
.chat-list{
  overflow:hidden;border-radius:13px;background:#fff;
  box-shadow:0 1px 3px rgba(23,33,43,.06);
}
.chat-list-row{
  display:grid;grid-template-columns:48px minmax(0,1fr) auto;gap:11px;align-items:center;
  min-height:70px;padding:10px 13px;color:inherit;text-decoration:none;
  border-bottom:1px solid var(--tg-line,#e7ebef);
}
.chat-list-row:last-child{border-bottom:0}
.chat-list-row:hover{background:rgba(127,145,160,.07)}
.chat-list-avatar{
  width:48px;height:48px;border-radius:50%;overflow:hidden;display:grid;place-items:center;
  background:linear-gradient(145deg,var(--accent-start,#75c3f5),var(--accent-end,#3390ec));
  color:#fff;font-weight:850;font-size:12px;
}
.chat-list-avatar img{width:100%;height:100%;display:block;object-fit:cover}
.chat-list-copy{min-width:0}
.chat-list-copy strong{display:block;font-size:14px;margin-bottom:4px}
.chat-list-copy small{display:block;color:var(--tg-muted,#708499);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-list-side{display:flex;flex-direction:column;align-items:flex-end;gap:7px;min-width:36px}
.chat-list-side>small{color:var(--tg-muted,#708499);font-size:9px}
.chat-unread-count{
  min-width:20px;height:20px;padding:0 5px;border-radius:999px;display:grid;place-items:center;
  background:#e64646;color:#fff!important;font-size:9px;font-weight:850;
}

/* Conversation */
.chat-page{
  max-width:760px;height:calc(100vh - 104px);min-height:480px;margin:0 auto;
  display:grid;grid-template-rows:auto minmax(0,1fr) auto;overflow:hidden;
  border-radius:14px;background:rgba(255,255,255,.92);box-shadow:0 2px 12px rgba(23,33,43,.08);
}
.chat-header{
  min-height:58px;padding:9px 12px;display:flex;align-items:center;gap:10px;
  border-bottom:1px solid var(--tg-line,#e7ebef);background:rgba(255,255,255,.78);
  backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
}
.chat-header>div{display:flex;flex-direction:column;min-width:0}
.chat-header strong{font-size:14px}
.chat-header small{color:var(--tg-muted,#708499);font-size:10px;margin-top:2px}
.chat-back{font-size:31px;line-height:1;text-decoration:none;color:var(--tg-blue);padding:0 3px}
.chat-thread{
  overflow-y:auto;padding:14px 13px 20px;display:flex;flex-direction:column;gap:7px;
  background:
    radial-gradient(circle at 18px 18px,rgba(51,144,236,.045) 1.3px,transparent 1.4px) 0 0/36px 36px,
    rgba(222,235,244,.52);
}
.chat-message{display:flex;width:100%}
.chat-message.incoming{justify-content:flex-start}
.chat-message.outgoing{justify-content:flex-end}
.chat-bubble{
  max-width:min(78%,520px);padding:8px 10px 6px;border-radius:12px 12px 12px 4px;
  background:#fff;color:#17212b;box-shadow:0 1px 1px rgba(23,33,43,.08);
}
.chat-message.outgoing .chat-bubble{
  background:var(--tg-blue,#3390ec);color:#fff;border-radius:12px 12px 4px 12px;
}
.chat-bubble p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.42;color:inherit!important}
.chat-bubble small{display:block;margin-top:3px;text-align:right;font-size:8.5px;color:#7d8b99!important}
.chat-message.outgoing .chat-bubble small{color:rgba(255,255,255,.72)!important}
.chat-empty{margin:auto;color:var(--tg-muted,#708499);font-size:11px;background:rgba(255,255,255,.70);padding:8px 10px;border-radius:999px}
.chat-compose{
  display:grid;grid-template-columns:minmax(0,1fr) 44px;gap:7px;padding:9px 10px;
  border-top:1px solid var(--tg-line,#e7ebef);background:rgba(255,255,255,.82);
  backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
}
.chat-compose textarea{min-height:42px;max-height:110px;resize:vertical;margin:0;border-radius:20px;padding:10px 13px}
.chat-compose button{width:42px;height:42px;min-height:42px;padding:0;border-radius:50%;display:grid;place-items:center;font-size:17px}

.telegram-ui.app-client.has-global-client-wallpaper .chat-page,
.telegram-ui.app-client.has-global-client-wallpaper .chat-header,
.telegram-ui.app-client.has-global-client-wallpaper .chat-compose{background:var(--client-surface-light,rgba(255,255,255,.82))}
.telegram-ui.app-client.has-global-client-wallpaper .chat-thread{background:rgba(214,229,239,.34)}
.telegram-ui.app-client.theme-dark .chat-page,
.telegram-ui.app-client.theme-dark .chat-header,
.telegram-ui.app-client.theme-dark .chat-compose,
.telegram-ui.trainer-personal-shell.theme-dark .chat-page,
.telegram-ui.trainer-personal-shell.theme-dark .chat-header,
.telegram-ui.trainer-personal-shell.theme-dark .chat-compose{background:var(--client-surface-dark,rgba(32,43,54,.88));border-color:#2d3a46;color:#f3f6f8}
.telegram-ui.app-client.theme-dark .chat-thread,
.telegram-ui.trainer-personal-shell.theme-dark .chat-thread{background:rgba(17,29,39,.72)}
.telegram-ui.app-client.theme-dark .chat-bubble,
.telegram-ui.trainer-personal-shell.theme-dark .chat-bubble{background:#273746;color:#f3f6f8}
.telegram-ui.app-client.theme-dark .chat-message.outgoing .chat-bubble,
.telegram-ui.trainer-personal-shell.theme-dark .chat-message.outgoing .chat-bubble{background:var(--tg-blue);color:#fff}
.telegram-ui.app-client.theme-dark .chat-list,
.telegram-ui.trainer-personal-shell.theme-dark .chat-list{background:var(--client-surface-dark,#202b36)}
.telegram-ui.app-client.theme-dark .chat-list-row,
.telegram-ui.trainer-personal-shell.theme-dark .chat-list-row{border-color:#2d3a46;color:#f3f6f8}

@media(prefers-color-scheme:dark){
  .telegram-ui.trainer-personal-shell.theme-system{background:#17212b;color:#f3f6f8}
  .telegram-ui.trainer-personal-shell.theme-system .app-topbar,
  .telegram-ui.trainer-personal-shell.theme-system .mobile-nav{background:rgba(32,43,54,.93)!important}
  .telegram-ui.trainer-personal-shell.theme-system .card,
  .telegram-ui.trainer-personal-shell.theme-system .day-card,
  .telegram-ui.trainer-personal-shell.theme-system .chat-list,
  .telegram-ui.trainer-personal-shell.theme-system .chat-page{background:rgba(32,43,54,.88);color:#f3f6f8}
}

@media(max-width:700px){
  .brand-app-icon{width:30px;height:30px;border-radius:9px}
  .app-settings-link{width:29px;height:29px}
  .mobile-nav{grid-template-columns:repeat(auto-fit,minmax(54px,1fr))}
  .mobile-nav a span{font-size:7.8px}
  .chat-list-row{grid-template-columns:44px minmax(0,1fr) auto;min-height:63px;padding:8px 10px;gap:9px}
  .chat-list-avatar{width:44px;height:44px}
  .chat-list-copy strong{font-size:13px}
  .chat-list-copy small{font-size:10px}
  .chat-page{height:calc(100dvh - 64px);min-height:430px;border-radius:11px;margin:0}
  .chat-thread{padding:11px 9px 16px}
  .chat-bubble{max-width:84%;padding:7px 9px 5px}
  .chat-bubble p{font-size:12px}
  .chat-compose{padding:7px 8px}
  .trainer-settings-page{padding-bottom:72px}
}
.hero-chat{
  color:var(--tg-blue);text-decoration:none;font-size:13px;font-weight:800;
  border-radius:10px;padding:9px 10px;background:var(--tg-blue-soft);
}
@media(max-width:700px){.hero-chat{padding:8px 9px;font-size:11px}}


/* =========================================================
   Stage 3.12.1 — Visual QA: popovers, contrast and Telegram chat
   ========================================================= */

/* Native browser popups (select/date controls) follow the selected theme. */
.telegram-ui.theme-light{color-scheme:light}
.telegram-ui.theme-dark{color-scheme:dark}
.telegram-ui.theme-system{color-scheme:light dark}

/* High transparency was visually attractive but too aggressive over mixed
   bright/dark photos. Keep the wallpaper visible while protecting text contrast. */
.telegram-ui.app-client.transparency-high{
  --client-surface-light:rgba(255,255,255,.74);
  --client-row-light:rgba(255,255,255,.58);
  --client-nav-light:rgba(255,255,255,.72);
  --client-field-light:rgba(255,255,255,.80);
  --client-surface-dark:rgba(32,43,54,.76);
  --client-row-dark:rgba(38,52,64,.64);
  --client-nav-dark:rgba(32,43,54,.75);
  --client-field-dark:rgba(32,43,54,.82);
  --client-blur:18px;
}
.telegram-ui.app-client.transparency-medium{
  --client-surface-light:rgba(255,255,255,.84);
  --client-row-light:rgba(255,255,255,.70);
  --client-nav-light:rgba(255,255,255,.82);
  --client-field-light:rgba(255,255,255,.88);
  --client-surface-dark:rgba(32,43,54,.86);
  --client-row-dark:rgba(38,52,64,.76);
  --client-nav-dark:rgba(32,43,54,.85);
  --client-field-dark:rgba(32,43,54,.90);
}

/* Trainer dark mode now respects the selected transparency level too. */
.telegram-ui.trainer-personal-shell.theme-dark.transparency-low{
  --trainer-surface:rgba(32,43,54,.96);
  --trainer-row:rgba(38,52,64,.92);
  --trainer-nav:rgba(32,43,54,.96);
  --trainer-field:rgba(32,43,54,.97);
  --trainer-blur:9px;
}
.telegram-ui.trainer-personal-shell.theme-dark.transparency-medium{
  --trainer-surface:rgba(32,43,54,.87);
  --trainer-row:rgba(38,52,64,.78);
  --trainer-nav:rgba(32,43,54,.88);
  --trainer-field:rgba(32,43,54,.91);
  --trainer-blur:14px;
}
.telegram-ui.trainer-personal-shell.theme-dark.transparency-high{
  --trainer-surface:rgba(32,43,54,.77);
  --trainer-row:rgba(38,52,64,.66);
  --trainer-nav:rgba(32,43,54,.78);
  --trainer-field:rgba(32,43,54,.83);
  --trainer-blur:18px;
}

/* System-dark gets the same readable text treatment as explicit dark mode. */
@media(prefers-color-scheme:dark){
  .telegram-ui.app-client.theme-system h1,
  .telegram-ui.app-client.theme-system h2,
  .telegram-ui.app-client.theme-system h3,
  .telegram-ui.app-client.theme-system h4,
  .telegram-ui.app-client.theme-system p,
  .telegram-ui.app-client.theme-system span,
  .telegram-ui.app-client.theme-system strong,
  .telegram-ui.app-client.theme-system small,
  .telegram-ui.app-client.theme-system label,
  .telegram-ui.app-client.theme-system li,
  .telegram-ui.app-client.theme-system summary,
  .telegram-ui.app-client.theme-system .program-row,
  .telegram-ui.app-client.theme-system .history-workout-row,
  .telegram-ui.app-client.theme-system .progress-history-row,
  .telegram-ui.app-client.theme-system .quick-action,
  .telegram-ui.app-client.theme-system .program-card-link,
  .telegram-ui.app-client.theme-system .extra-row,
  .telegram-ui.app-client.theme-system .set-row,
  .telegram-ui.app-client.theme-system .settings-row,
  .telegram-ui.app-client.theme-system .settings-toggle{
    color:#f3f6f8!important;
  }
  .telegram-ui.app-client.theme-system .muted,
  .telegram-ui.app-client.theme-system .program-row span,
  .telegram-ui.app-client.theme-system .history-workout-main span,
  .telegram-ui.app-client.theme-system .history-workout-meta small,
  .telegram-ui.app-client.theme-system .settings-row small,
  .telegram-ui.app-client.theme-system .settings-toggle small{
    color:#b6c4cf!important;
  }
  .telegram-ui.app-client.theme-system a:not(.button):not(.quick-action):not(.program-row):not(.history-workout-row){
    color:#72baf5;
  }
  .telegram-ui.app-client.theme-system input::placeholder,
  .telegram-ui.app-client.theme-system textarea::placeholder{
    color:#93a5b3!important;
  }
}

/* ---------- Popovers / dropdown panels ---------- */
/* Backdrop-filter creates stacking contexts on cards. Elevate the hero while
   its actions menu is open so the popup cannot disappear under the next card. */
.athlete-hero:has(.athlete-actions-menu[open]){
  position:relative;
  z-index:260;
  overflow:visible;
}
.athlete-actions-menu{
  position:relative;
  z-index:270;
}
.action-menu-panel{
  z-index:320;
  top:calc(100% + 7px);
  right:0;
  left:auto;
  width:min(240px,calc(100vw - 28px));
  padding:6px;
  border-radius:13px;
  background:rgba(255,255,255,.98)!important;
  border:1px solid rgba(120,145,165,.24)!important;
  box-shadow:0 14px 38px rgba(15,23,42,.22),0 2px 8px rgba(15,23,42,.08);
  backdrop-filter:blur(18px) saturate(130%);
  -webkit-backdrop-filter:blur(18px) saturate(130%);
}
.action-menu-panel a,
.action-menu-panel button{
  min-height:40px;
  display:flex;
  align-items:center;
  width:100%;
  margin:0;
  padding:9px 11px;
  border:0!important;
  border-radius:9px;
  background:transparent!important;
  color:#17212b!important;
  text-align:left;
  text-decoration:none;
  font:inherit;
  font-size:12px;
  font-weight:700;
  box-shadow:none!important;
}
.action-menu-panel a:hover,
.action-menu-panel button:hover{
  background:rgba(112,132,148,.10)!important;
}
.action-menu-panel form{
  display:block;
  margin:0;
  padding:0;
}
.athlete-actions-menu[open]>summary{
  background:var(--tg-blue-soft)!important;
  color:var(--tg-blue)!important;
}

/* Dark popovers must be dark too — the old build left them white. */
.telegram-ui.theme-dark .action-menu-panel{
  background:rgba(32,43,54,.97)!important;
  border-color:rgba(155,180,200,.18)!important;
  box-shadow:0 16px 42px rgba(0,0,0,.40),0 2px 8px rgba(0,0,0,.24);
}
.telegram-ui.theme-dark .action-menu-panel a,
.telegram-ui.theme-dark .action-menu-panel button{
  color:#f3f6f8!important;
}
.telegram-ui.theme-dark .action-menu-panel a:hover,
.telegram-ui.theme-dark .action-menu-panel button:hover{
  background:rgba(125,155,180,.14)!important;
}
@media(prefers-color-scheme:dark){
  .telegram-ui.theme-system .action-menu-panel{
    background:rgba(32,43,54,.97)!important;
    border-color:rgba(155,180,200,.18)!important;
  }
  .telegram-ui.theme-system .action-menu-panel a,
  .telegram-ui.theme-system .action-menu-panel button{
    color:#f3f6f8!important;
  }
}

/* ---------- Telegram-inspired conversation ---------- */
.chat-page{
  max-width:780px;
  border:1px solid rgba(120,145,165,.12);
  box-shadow:0 4px 18px rgba(23,33,43,.10);
}
.chat-header{
  min-height:60px;
  padding:8px 12px;
  background:rgba(255,255,255,.90);
  border-bottom:1px solid rgba(120,145,165,.16);
}
.chat-back{
  width:28px;
  height:38px;
  display:grid;
  place-items:center;
  flex:0 0 28px;
  padding:0;
  font-size:31px;
}
.chat-peer-avatar{
  width:38px;
  height:38px;
  flex:0 0 38px;
  border-radius:50%;
  overflow:hidden;
  display:grid;
  place-items:center;
  background:linear-gradient(145deg,var(--accent-start,#75c3f5),var(--accent-end,#3390ec));
  color:#fff!important;
  font-size:10px;
  font-weight:850;
}
.chat-peer-avatar img{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
}
.chat-peer-copy{
  min-width:0;
  display:flex;
  flex-direction:column;
}
.chat-peer-copy strong{
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:14px;
}
.chat-peer-copy small{
  margin-top:1px;
  color:var(--tg-muted,#708499);
  font-size:9.5px;
}

.chat-thread{
  position:relative;
  gap:4px;
  padding:13px 12px 18px;
  scrollbar-width:thin;
  scrollbar-color:rgba(112,132,148,.28) transparent;
  background:
    radial-gradient(circle at 18px 18px,rgba(51,144,236,.04) 1.2px,transparent 1.3px) 0 0/36px 36px,
    rgba(214,229,239,.34);
}
.chat-date-separator{
  position:sticky;
  top:4px;
  z-index:2;
  display:flex;
  justify-content:center;
  margin:5px 0 7px;
  pointer-events:none;
}
.chat-date-separator span{
  display:inline-flex;
  align-items:center;
  min-height:24px;
  padding:4px 9px;
  border-radius:999px;
  background:rgba(83,112,134,.58);
  color:#fff!important;
  font-size:9px;
  font-weight:750;
  box-shadow:0 1px 2px rgba(23,33,43,.10);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
}

.chat-message{
  position:relative;
  display:flex;
  width:100%;
  margin:1px 0;
}
.chat-bubble{
  position:relative;
  max-width:min(76%,540px);
  min-width:62px;
  padding:7px 9px 5px;
  border-radius:12px 12px 12px 5px;
  background:rgba(255,255,255,.96);
  color:#17212b;
  box-shadow:0 1px 1px rgba(23,33,43,.10);
}
.chat-message.incoming .chat-bubble::after,
.chat-message.outgoing .chat-bubble::after{
  content:"";
  position:absolute;
  bottom:0;
  width:7px;
  height:9px;
  background:inherit;
}
.chat-message.incoming .chat-bubble::after{
  left:-4px;
  clip-path:polygon(100% 0,100% 100%,0 100%);
}
.chat-message.outgoing .chat-bubble{
  border-radius:12px 12px 5px 12px;
  background:var(--tg-blue);
  background:color-mix(in srgb,var(--tg-blue) 24%,#ffffff);
  color:#17212b;
}
.chat-message.outgoing .chat-bubble::after{
  right:-4px;
  clip-path:polygon(0 0,100% 100%,0 100%);
}
.chat-bubble p{
  margin:0;
  color:inherit!important;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  font-family:inherit;
  font-size:13px;
  line-height:1.38;
}
.chat-meta{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:3px;
  min-height:12px;
  margin-top:2px;
  color:#7c8d9b!important;
  font-size:8.5px!important;
  line-height:1;
  white-space:nowrap;
}
.chat-meta time{
  color:inherit!important;
  font:inherit;
}
.chat-checks{
  color:color-mix(in srgb,var(--tg-blue) 84%,#4f6576)!important;
  font-size:9px!important;
  letter-spacing:-2px;
  padding-right:1px;
}
.chat-message.outgoing .chat-meta{
  color:#587086!important;
}
.chat-message.outgoing .chat-checks{
  color:var(--tg-blue)!important;
}
.chat-empty{
  align-self:center;
  margin:auto;
  color:#5f7285;
  background:rgba(255,255,255,.78);
  backdrop-filter:blur(9px);
  -webkit-backdrop-filter:blur(9px);
}

.chat-compose{
  grid-template-columns:minmax(0,1fr) 42px;
  gap:7px;
  padding:7px 9px;
  background:rgba(255,255,255,.92);
  border-top:1px solid rgba(120,145,165,.16);
}
.chat-compose textarea{
  min-height:40px;
  height:40px;
  max-height:120px;
  resize:none;
  overflow-y:auto;
  margin:0;
  padding:9px 13px;
  border-radius:20px;
  border:1px solid rgba(120,145,165,.24)!important;
  background:rgba(255,255,255,.94)!important;
  color:#17212b!important;
  font-family:inherit!important;
  line-height:1.3;
}
.chat-compose textarea::placeholder{
  color:#8293a2!important;
}
.chat-compose button{
  width:40px;
  height:40px;
  min-height:40px;
  padding:0;
  border-radius:50%;
  background:var(--tg-blue)!important;
  color:#fff!important;
  box-shadow:none;
}
.chat-compose button span{
  display:block;
  transform:translateX(1px);
  color:#fff!important;
  font-size:15px;
}

/* Dark Telegram-like bubbles. */
.telegram-ui.theme-dark .chat-page,
.telegram-ui.theme-dark .chat-header,
.telegram-ui.theme-dark .chat-compose{
  background:rgba(32,43,54,.92)!important;
  border-color:rgba(155,180,200,.13)!important;
}
.telegram-ui.theme-dark .chat-thread{
  background:
    radial-gradient(circle at 18px 18px,rgba(115,177,220,.035) 1.2px,transparent 1.3px) 0 0/36px 36px,
    rgba(13,24,33,.60)!important;
}
.telegram-ui.theme-dark .chat-bubble{
  background:rgba(40,56,70,.97)!important;
  color:#f3f6f8!important;
}
.telegram-ui.theme-dark .chat-message.outgoing .chat-bubble{
  background:var(--tg-blue)!important;
  background:color-mix(in srgb,var(--tg-blue) 42%,#263746)!important;
  color:#f7fafc!important;
}
.telegram-ui.theme-dark .chat-meta{
  color:#aebdca!important;
}
.telegram-ui.theme-dark .chat-message.outgoing .chat-meta{
  color:#d2e0ea!important;
}
.telegram-ui.theme-dark .chat-checks,
.telegram-ui.theme-dark .chat-message.outgoing .chat-checks{
  color:#8ed4ff!important;
}
.telegram-ui.theme-dark .chat-compose textarea{
  background:rgba(27,39,49,.96)!important;
  color:#f5f7f9!important;
  border-color:rgba(155,180,200,.18)!important;
}
.telegram-ui.theme-dark .chat-compose textarea::placeholder{
  color:#8fa2b2!important;
}
.telegram-ui.theme-dark .chat-peer-copy small,
.telegram-ui.theme-dark .chat-list-copy small,
.telegram-ui.theme-dark .chat-list-side>small{
  color:#aebdca!important;
}
.telegram-ui.theme-dark .chat-empty{
  background:rgba(52,69,82,.80);
  color:#d9e3ea!important;
}

/* System dark mirrors explicit dark chat contrast. */
@media(prefers-color-scheme:dark){
  .telegram-ui.theme-system .chat-page,
  .telegram-ui.theme-system .chat-header,
  .telegram-ui.theme-system .chat-compose{
    background:rgba(32,43,54,.92)!important;
    border-color:rgba(155,180,200,.13)!important;
  }
  .telegram-ui.theme-system .chat-thread{
    background:rgba(13,24,33,.60)!important;
  }
  .telegram-ui.theme-system .chat-bubble{
    background:rgba(40,56,70,.97)!important;
    color:#f3f6f8!important;
  }
  .telegram-ui.theme-system .chat-message.outgoing .chat-bubble{
    background:color-mix(in srgb,var(--tg-blue) 42%,#263746)!important;
    color:#f7fafc!important;
  }
  .telegram-ui.theme-system .chat-compose textarea{
    background:rgba(27,39,49,.96)!important;
    color:#f5f7f9!important;
  }
  .telegram-ui.theme-system .chat-peer-copy small,
  .telegram-ui.theme-system .chat-list-copy small,
  .telegram-ui.theme-system .chat-list-side>small{
    color:#aebdca!important;
  }
}

/* Personal wallpaper remains visible behind the thread, like Telegram chat wallpaper. */
.telegram-ui.app-client.has-global-client-wallpaper .chat-thread{
  background:
    linear-gradient(rgba(215,231,241,.12),rgba(215,231,241,.12))!important;
}
.telegram-ui.app-client.has-global-client-wallpaper.theme-dark .chat-thread{
  background:
    linear-gradient(rgba(9,18,26,.30),rgba(9,18,26,.30))!important;
}

/* Conversation list also keeps preview hierarchy in dark mode. */
.telegram-ui.theme-dark .chat-list-row,
.telegram-ui.theme-dark .chat-list-copy strong{
  color:#f3f6f8!important;
}
.telegram-ui.theme-dark .chat-list-copy small,
.telegram-ui.theme-dark .chat-list-side>small{
  color:#aebdca!important;
}

/* Mobile: fit the whole chat between the sticky app header and bottom navigation.
   Previous build could place the composer below/behind the nav. */
@media(max-width:700px){
  .telegram-ui.has-mobile-nav .chat-page{
    height:calc(100dvh - 50px - 58px - 18px);
    min-height:0;
    margin:0 auto;
    border-radius:11px;
  }
  .chat-header{
    min-height:54px;
    padding:7px 9px;
  }
  .chat-peer-avatar{
    width:35px;
    height:35px;
    flex-basis:35px;
  }
  .chat-thread{
    padding:10px 9px 13px;
  }
  .chat-bubble{
    max-width:86%;
    padding:7px 9px 5px;
  }
  .chat-bubble p{
    font-size:12px;
  }
  .chat-compose{
    padding:6px 8px;
  }
  .chat-compose textarea{
    min-height:38px;
    height:38px;
    padding:8px 12px;
  }
  .chat-compose button{
    width:38px;
    height:38px;
    min-height:38px;
  }
}

/* Protect readability of hard-coded historical text over personalized backgrounds. */
.telegram-ui.app-client.theme-dark .athlete-note-card p,
.telegram-ui.app-client.theme-dark .program-block p,
.telegram-ui.app-client.theme-dark .program-block li,
.telegram-ui.app-client.theme-dark .exercise-result p,
.telegram-ui.app-client.theme-dark .set-row,
.telegram-ui.trainer-personal-shell.theme-dark .athlete-note-card p,
.telegram-ui.trainer-personal-shell.theme-dark .program-block p,
.telegram-ui.trainer-personal-shell.theme-dark .program-block li,
.telegram-ui.trainer-personal-shell.theme-dark .exercise-result p,
.telegram-ui.trainer-personal-shell.theme-dark .set-row{
  color:#f3f6f8!important;
}
.telegram-ui.app-client.theme-dark .program-block,
.telegram-ui.trainer-personal-shell.theme-dark .program-block{
  border-color:rgba(160,185,205,.13)!important;
}


/* Final popover readability: menus are intentionally opaque even when the
   surrounding interface is transparent. */
.action-menu-panel{
  background:#ffffff!important;
}
.telegram-ui.theme-dark .action-menu-panel{
  background:#202b36!important;
}
@media(prefers-color-scheme:dark){
  .telegram-ui.theme-system .action-menu-panel{
    background:#202b36!important;
  }
}


/* =========================================================
   Stage 3.12.2 — Athlete-card dark-theme cleanup
   Fixes remaining light islands visible in trainer dark mode.
   ========================================================= */

/* These compact athlete-card components predate trainer theming and carried
   hard-coded light backgrounds. Give them explicit theme-aware surfaces. */
.telegram-ui.trainer-personal-shell.theme-dark .athlete-chart-empty,
.telegram-ui.app-client.theme-dark .athlete-chart-empty{
  background:rgba(38,52,64,.82)!important;
  color:#b9c7d2!important;
  border:1px solid rgba(157,181,200,.10);
}

.telegram-ui.trainer-personal-shell.theme-dark .measurement-strip,
.telegram-ui.app-client.theme-dark .measurement-strip{
  background:rgba(38,52,64,.76)!important;
  border:1px solid rgba(157,181,200,.12)!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .measurement-chip,
.telegram-ui.app-client.theme-dark .measurement-chip{
  background:transparent!important;
  border-color:rgba(157,181,200,.12)!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .measurement-chip span,
.telegram-ui.app-client.theme-dark .measurement-chip span{
  color:#aebdca!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .measurement-chip strong,
.telegram-ui.app-client.theme-dark .measurement-chip strong{
  color:#f4f7f9!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .measurement-chip small,
.telegram-ui.app-client.theme-dark .measurement-chip small{
  color:#7fd99b!important;
}

.telegram-ui.trainer-personal-shell.theme-dark .status-pill,
.telegram-ui.app-client.theme-dark .status-pill{
  color:#d9e4eb!important;
  background:rgba(94,119,139,.30)!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .status-active,
.telegram-ui.app-client.theme-dark .status-active{
  color:#8bdda2!important;
  background:rgba(49,162,76,.17)!important;
}

.telegram-ui.trainer-personal-shell.theme-dark .program-card-link,
.telegram-ui.trainer-personal-shell.theme-dark .quick-action,
.telegram-ui.trainer-personal-shell.theme-dark .athlete-extra-grid>div,
.telegram-ui.trainer-personal-shell.theme-dark .extra-row,
.telegram-ui.app-client.theme-dark .program-card-link,
.telegram-ui.app-client.theme-dark .quick-action,
.telegram-ui.app-client.theme-dark .athlete-extra-grid>div,
.telegram-ui.app-client.theme-dark .extra-row{
  background:rgba(38,52,64,.76)!important;
  color:#f3f6f8!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .program-card-main span,
.telegram-ui.trainer-personal-shell.theme-dark .athlete-history-link small,
.telegram-ui.trainer-personal-shell.theme-dark .athlete-extra-grid span,
.telegram-ui.app-client.theme-dark .program-card-main span,
.telegram-ui.app-client.theme-dark .athlete-history-link small,
.telegram-ui.app-client.theme-dark .athlete-extra-grid span{
  color:#aebdca!important;
}

.telegram-ui.trainer-personal-shell.theme-dark .compact-progress,
.telegram-ui.app-client.theme-dark .compact-progress{
  background:rgba(128,153,174,.18)!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .compact-progress i,
.telegram-ui.app-client.theme-dark .compact-progress i{
  background:var(--tg-blue)!important;
}

/* SVG weight chart must not contain bright white dots/grid in dark mode. */
.telegram-ui.trainer-personal-shell.theme-dark .athlete-weight-chart .chart-grid,
.telegram-ui.app-client.theme-dark .athlete-weight-chart .chart-grid{
  stroke:rgba(170,192,208,.16)!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .athlete-weight-chart circle,
.telegram-ui.app-client.theme-dark .athlete-weight-chart circle{
  fill:#202b36!important;
  stroke:currentColor!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .weight-current strong,
.telegram-ui.app-client.theme-dark .weight-current strong{
  color:#f5f8fa!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .delta-neutral,
.telegram-ui.app-client.theme-dark .delta-neutral{
  color:#aebdca!important;
}

/* Collapsible inline forms are part of the same card and should not reveal a
   leftover light border/surface when opened. */
.telegram-ui.trainer-personal-shell.theme-dark .compact-entry-form,
.telegram-ui.trainer-personal-shell.theme-dark .compact-measurement-form,
.telegram-ui.app-client.theme-dark .compact-entry-form,
.telegram-ui.app-client.theme-dark .compact-measurement-form{
  border-color:rgba(157,181,200,.13)!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .compact-entry-form label>span,
.telegram-ui.trainer-personal-shell.theme-dark .compact-measurement-form label>span,
.telegram-ui.app-client.theme-dark .compact-entry-form label>span,
.telegram-ui.app-client.theme-dark .compact-measurement-form label>span{
  border-color:rgba(157,181,200,.18)!important;
  background:rgba(32,43,54,.64)!important;
}

/* System dark should receive the same cleanup. */
@media(prefers-color-scheme:dark){
  .telegram-ui.theme-system .athlete-chart-empty{
    background:rgba(38,52,64,.82)!important;
    color:#b9c7d2!important;
  }
  .telegram-ui.theme-system .measurement-strip{
    background:rgba(38,52,64,.76)!important;
    border-color:rgba(157,181,200,.12)!important;
  }
  .telegram-ui.theme-system .measurement-chip{
    border-color:rgba(157,181,200,.12)!important;
  }
  .telegram-ui.theme-system .measurement-chip strong{
    color:#f4f7f9!important;
  }
  .telegram-ui.theme-system .status-pill{
    color:#d9e4eb!important;
    background:rgba(94,119,139,.30)!important;
  }
  .telegram-ui.theme-system .program-card-link,
  .telegram-ui.theme-system .quick-action,
  .telegram-ui.theme-system .athlete-extra-grid>div{
    background:rgba(38,52,64,.76)!important;
    color:#f3f6f8!important;
  }
}

/* The empty-chart message and empty measurement values must stay legible at
   every trainer font size, including small. */
.athlete-chart-empty span,
.measurement-chip span,
.measurement-chip strong,
.measurement-chip small{
  text-shadow:none!important;
}


/* =========================================================
   Stage 3.12.3 — Display regression cleanup
   - invisible primary anchor buttons on trainer accent themes
   - clipped athlete actions dropdown
   - dark-theme checkbox/equipment tiles
   ========================================================= */

/* 1) Accent link coloring must NOT repaint filled buttons to the same accent
   color as their background. Keep regular links accented, but preserve
   button contrast. */
.telegram-ui.trainer-personal-shell[class*="accent-"] a:not(.button):not(.client-list-card):not(.program-row):not(.history-workout-row){
  color:var(--tg-blue);
}
.telegram-ui.trainer-personal-shell button:not(.secondary),
.telegram-ui.trainer-personal-shell .button:not(.secondary),
.telegram-ui.trainer-personal-shell[class*="accent-"] a.button:not(.secondary),
.telegram-ui.trainer-personal-shell[class*="accent-"] .button:not(.secondary){
  color:#fff !important;
}
.telegram-ui.trainer-personal-shell .button.secondary,
.telegram-ui.trainer-personal-shell a.button.secondary{
  color:var(--tg-blue) !important;
}
.telegram-ui.trainer-personal-shell.theme-dark .button.secondary,
.telegram-ui.trainer-personal-shell.theme-dark a.button.secondary{
  color:#7bc0f8 !important;
}

/* 2) The athlete actions popup must open above surrounding cards and remain
   fully visible instead of looking cropped on the left edge. */
.athlete-hero,
.athlete-hero-controls,
.athlete-actions-menu{
  overflow:visible;
}
.athlete-hero-controls{
  align-items:flex-start;
}
.athlete-actions-menu{
  isolation:isolate;
}
.athlete-actions-menu[open]{
  z-index:420;
}
.athlete-actions-menu .action-menu-panel{
  position:absolute;
  top:calc(100% + 7px);
  right:0 !important;
  left:auto !important;
  min-width:220px;
  max-width:min(260px, calc(100vw - 28px));
  transform:none !important;
}

/* 3) Equipment / checkbox tiles in dark trainer mode were still rendering as
   almost white blocks with pale text. Give them proper dark surfaces and keep
   checked state readable. */
.telegram-ui.trainer-personal-shell.theme-dark .check,
.telegram-ui.theme-dark .check{
  background:rgba(38,52,64,.82) !important;
  border-color:rgba(157,181,200,.18) !important;
  color:#f3f6f8 !important;
}
.telegram-ui.trainer-personal-shell.theme-dark .check input,
.telegram-ui.theme-dark .check input{
  accent-color:var(--tg-blue);
}
.telegram-ui.trainer-personal-shell.theme-dark .check:has(input:checked),
.telegram-ui.theme-dark .check:has(input:checked){
  background:rgba(74,118,161,.22) !important;
  border-color:rgba(113,174,231,.45) !important;
  color:#f5f8fa !important;
}
.telegram-ui.trainer-personal-shell.theme-dark .exercise-pref-row small,
.telegram-ui.theme-dark .exercise-pref-row small{
  color:#b6c4cf !important;
}

/* 4) Success cards should stay readable in dark trainer mode as well. */
.telegram-ui.trainer-personal-shell.theme-dark .validation-ok,
.telegram-ui.theme-dark .validation-ok{
  background:rgba(24,54,40,.42) !important;
  color:#eef8f1 !important;
  border-left-color:#31c56a !important;
}
.telegram-ui.trainer-personal-shell.theme-dark .validation-ok p,
.telegram-ui.trainer-personal-shell.theme-dark .validation-ok h1,
.telegram-ui.theme-dark .validation-ok p,
.telegram-ui.theme-dark .validation-ok h1{
  color:#eef8f1 !important;
}

/* 5) Small polish for primary action rows in trainer shells. */
.telegram-ui.trainer-personal-shell .title-row .actions .button:not(.secondary){
  white-space:nowrap;
}


/* =========================================================
   Stage 3.13.0 — Explicit Mesocycle / Microcycle entities
   ========================================================= */
.mesocycle-context{
  display:flex;
  align-items:center;
  gap:8px 12px;
  flex-wrap:wrap;
  margin:10px 0 14px;
}
.mesocycle-context strong{font-size:12px}
.mesocycle-context .text-link{margin-left:auto}
.microcycle-actions{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin-top:10px;
}
.settings-choice-fieldset{
  display:grid;
  gap:7px;
  padding:12px;
  border:1px solid var(--fc-border-soft,#e7ebef);
  border-radius:11px;
}
.settings-choice-fieldset legend{
  padding:0 6px;
  font-size:11px;
  font-weight:800;
}
.mesocycle-current-note{margin:12px 0}
.mesocycle-current-note>span{font-size:11px}
.mesocycle-current-note p{margin:7px 0 0}
.telegram-ui.theme-dark .settings-choice-fieldset,
.telegram-ui.trainer-personal-shell.theme-dark .settings-choice-fieldset{
  border-color:rgba(157,181,200,.18);
}
@media(max-width:700px){
  .mesocycle-context .text-link{margin-left:0}
  .microcycle-actions{align-items:flex-start;flex-direction:column;gap:7px}
}

/* =========================================================
   Stage 3.14.0 — Cycle mode, trainer reminders, draft additions,
   and remaining dark-theme display fixes.
   ========================================================= */

/* Cycle mode controls */
.microcycle-actions{align-items:center;flex-wrap:wrap}
.cycle-mode-form{display:inline-flex;margin:0}
.cycle-mode-toggle{min-height:30px;padding:5px 9px;font-size:10px;white-space:nowrap}
.microcycle-only-context{border-color:rgba(51,144,236,.18)}
.structure-add-actions{display:flex;gap:7px;flex-wrap:wrap;justify-content:flex-end}

/* Trainer reminders replace the old quick-navigation tile. */
.athlete-reminders-card{min-height:180px}
.trainer-reminder-list{display:grid;gap:7px;margin-top:10px}
.trainer-reminder-row{
  display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:center;
  padding:10px 11px;border-radius:10px;background:#f7f9fb;border:1px solid #edf1f4
}
.trainer-reminder-row strong{display:block;font-size:12px;line-height:1.35}
.trainer-reminder-row small{display:block;margin-top:3px;color:var(--tg-muted,#708499);font-size:9.5px}
.trainer-reminder-row.is-due{border-color:#fecaca;background:#fff7f7}
.trainer-reminder-row.is-due small{color:#c24141}
.trainer-reminder-row-actions{display:flex;align-items:center;gap:4px}
.trainer-reminder-row-actions form{display:block;margin:0}
.trainer-reminder-row-actions button{min-height:31px;padding:5px 8px;font-size:9px}
.reminder-entry{margin-top:10px}
.reminder-form{grid-template-columns:minmax(0,1fr) minmax(170px,.7fr) auto;gap:8px;align-items:end}
.reminder-form button{min-height:42px}

/* In-app reminder popup. */
.trainer-reminder-toast-stack{
  position:fixed;right:18px;top:76px;z-index:1200;width:min(360px,calc(100vw - 24px));
  display:grid;gap:8px;pointer-events:none
}
.trainer-reminder-toast{
  pointer-events:auto;padding:13px;border-radius:14px;background:rgba(255,255,255,.97);
  border:1px solid rgba(120,145,165,.18);box-shadow:0 18px 45px rgba(15,23,42,.22);
  backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);color:#17212b
}
.trainer-reminder-toast-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
.trainer-reminder-toast-head strong{font-size:12px}
.trainer-reminder-toast-head small{color:#708499;font-size:9px;white-space:nowrap}
.trainer-reminder-toast p{margin:8px 0 10px;font-size:12px;line-height:1.4}
.trainer-reminder-toast-actions{display:flex;gap:7px;justify-content:flex-end}
.trainer-reminder-toast-actions .button,.trainer-reminder-toast-actions button{min-height:33px;padding:6px 10px;font-size:10px}

/* Draft: explicit add exercise / add block controls. */
.draft-add-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin:12px 0 14px}
.draft-add-card{border:1px solid var(--fc-border-soft,#eef2f7);border-radius:11px;background:#f8fafc;overflow:hidden}
.draft-add-card>summary{cursor:pointer;padding:11px 12px;font-size:11px;font-weight:800;color:var(--tg-blue,#3390ec)}
.draft-add-card>form{padding:0 12px 12px;gap:9px}

/* Screenshot fix: draft replacement rows must follow the dark theme instead of
   remaining white with nearly invisible text. */
.telegram-ui.trainer-personal-shell.theme-dark .draft-exercise-row,
.telegram-ui.theme-dark .draft-exercise-row,
.telegram-ui.trainer-personal-shell.theme-dark .draft-add-card,
.telegram-ui.theme-dark .draft-add-card{
  background:rgba(38,52,64,.82)!important;
  border-color:rgba(157,181,200,.15)!important;
  color:#f3f6f8!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .draft-exercise-row strong,
.telegram-ui.trainer-personal-shell.theme-dark .draft-exercise-row span,
.telegram-ui.trainer-personal-shell.theme-dark .draft-exercise-row label,
.telegram-ui.theme-dark .draft-exercise-row strong,
.telegram-ui.theme-dark .draft-exercise-row span,
.telegram-ui.theme-dark .draft-exercise-row label{
  color:#f3f6f8!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .draft-exercise-row small,
.telegram-ui.trainer-personal-shell.theme-dark .draft-exercise-row .muted,
.telegram-ui.theme-dark .draft-exercise-row small,
.telegram-ui.theme-dark .draft-exercise-row .muted{
  color:#aebdca!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .draft-exercise-form select,
.telegram-ui.trainer-personal-shell.theme-dark .draft-add-card select,
.telegram-ui.trainer-personal-shell.theme-dark .draft-add-card input,
.telegram-ui.theme-dark .draft-exercise-form select,
.telegram-ui.theme-dark .draft-add-card select,
.telegram-ui.theme-dark .draft-add-card input{
  background:#202b36!important;color:#f3f6f8!important;border-color:#405160!important
}

/* Screenshot fix: active athlete pills on the trainer list were a light pill
   with light text. */
.telegram-ui.trainer-personal-shell.theme-dark .client-list-status,
.telegram-ui.theme-dark .client-list-status{
  background:rgba(49,162,76,.18)!important;
  color:#8bdda2!important;
  border:1px solid rgba(95,205,126,.18)
}

/* Reminder surfaces in dark trainer theme. */
.telegram-ui.trainer-personal-shell.theme-dark .trainer-reminder-row,
.telegram-ui.theme-dark .trainer-reminder-row{
  background:rgba(38,52,64,.76)!important;border-color:rgba(157,181,200,.13)!important;color:#f3f6f8!important
}
.telegram-ui.trainer-personal-shell.theme-dark .trainer-reminder-row small,
.telegram-ui.theme-dark .trainer-reminder-row small{color:#aebdca!important}
.telegram-ui.trainer-personal-shell.theme-dark .trainer-reminder-row.is-due,
.telegram-ui.theme-dark .trainer-reminder-row.is-due{
  background:rgba(111,39,46,.34)!important;border-color:rgba(248,113,113,.30)!important
}
.telegram-ui.trainer-personal-shell.theme-dark .trainer-reminder-row.is-due small,
.telegram-ui.theme-dark .trainer-reminder-row.is-due small{color:#ff9f9f!important}
.telegram-ui.trainer-personal-shell.theme-dark .trainer-reminder-toast,
.telegram-ui.theme-dark .trainer-reminder-toast{
  background:rgba(32,43,54,.98);border-color:rgba(157,181,200,.16);color:#f3f6f8
}
.telegram-ui.trainer-personal-shell.theme-dark .trainer-reminder-toast p,
.telegram-ui.trainer-personal-shell.theme-dark .trainer-reminder-toast strong,
.telegram-ui.theme-dark .trainer-reminder-toast p,
.telegram-ui.theme-dark .trainer-reminder-toast strong{color:#f3f6f8!important}
.telegram-ui.trainer-personal-shell.theme-dark .trainer-reminder-toast small,
.telegram-ui.theme-dark .trainer-reminder-toast small{color:#aebdca!important}

@media(prefers-color-scheme:dark){
  .telegram-ui.theme-system .draft-exercise-row,
  .telegram-ui.theme-system .draft-add-card,
  .telegram-ui.theme-system .trainer-reminder-row{
    background:rgba(38,52,64,.82)!important;border-color:rgba(157,181,200,.15)!important;color:#f3f6f8!important
  }
  .telegram-ui.theme-system .client-list-status{background:rgba(49,162,76,.18)!important;color:#8bdda2!important}
}

@media(max-width:700px){
  .structure-add-actions{width:100%;justify-content:flex-start;flex-wrap:nowrap;overflow-x:auto}
  .structure-add-actions button{flex:0 0 auto}
  .draft-add-grid{grid-template-columns:1fr}
  .reminder-form{grid-template-columns:1fr}
  .trainer-reminder-row{grid-template-columns:1fr}
  .trainer-reminder-row-actions{justify-content:flex-start}
  .trainer-reminder-toast-stack{right:8px;top:58px;width:calc(100vw - 16px)}
}


/* =========================================================
   Stage 3.14.1 — Personal Block Library + dark UI cleanup
   ========================================================= */

/* Library tabs */
.library-tabs{
  display:flex;
  gap:6px;
  margin:0 0 10px;
  padding:4px;
  width:max-content;
  max-width:100%;
  border-radius:11px;
  background:rgba(255,255,255,.66);
  border:1px solid rgba(120,145,165,.14);
  overflow-x:auto;
}
.library-tab{
  flex:0 0 auto;
  padding:8px 12px;
  border-radius:8px;
  color:var(--tg-muted,#708499)!important;
  text-decoration:none;
  font-size:11px;
  font-weight:750;
}
.library-tab.is-active{
  background:var(--tg-blue,#3390ec);
  color:#fff!important;
}
.library-block-row{grid-template-columns:minmax(0,1fr) auto auto}
.library-block-row small+small{margin-top:2px}
.library-status{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:24px;
  padding:4px 8px;
  border-radius:999px;
  background:#eef4f8;
  color:#607383;
  font-size:9px;
  font-weight:800;
  white-space:nowrap;
}
.library-status-warning{background:#fff2d8;color:#a35b00}
.block-library-form .wide button{width:100%}

/* Screenshot-driven dark cleanup. The profile preference list was still using
   its original #f9fafb row surface, leaving almost invisible text. */
.telegram-ui.trainer-personal-shell.theme-dark .exercise-pref-list,
.telegram-ui.theme-dark .exercise-pref-list{
  color:#f3f6f8;
}
.telegram-ui.trainer-personal-shell.theme-dark .exercise-pref-row,
.telegram-ui.theme-dark .exercise-pref-row{
  background:rgba(38,52,64,.82)!important;
  border:1px solid rgba(157,181,200,.14)!important;
  color:#f3f6f8!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .exercise-pref-row strong,
.telegram-ui.trainer-personal-shell.theme-dark .exercise-pref-row label,
.telegram-ui.theme-dark .exercise-pref-row strong,
.telegram-ui.theme-dark .exercise-pref-row label{
  color:#f3f6f8!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .exercise-pref-row small,
.telegram-ui.theme-dark .exercise-pref-row small{
  color:#aebdca!important;
}

/* Old components that can still surface on trainer pages now share one dark
   surface language instead of relying on scattered per-screen fixes. */
.telegram-ui.trainer-personal-shell.theme-dark .profile-box,
.telegram-ui.trainer-personal-shell.theme-dark .card-subtle,
.telegram-ui.trainer-personal-shell.theme-dark .set-row.readonly,
.telegram-ui.trainer-personal-shell.theme-dark .progress-history-row,
.telegram-ui.trainer-personal-shell.theme-dark .library-row,
.telegram-ui.trainer-personal-shell.theme-dark .report-row,
.telegram-ui.trainer-personal-shell.theme-dark .manual-picker,
.telegram-ui.trainer-personal-shell.theme-dark .format-day{
  background:rgba(38,52,64,.78)!important;
  border-color:rgba(157,181,200,.14)!important;
  color:#f3f6f8!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .profile-box strong,
.telegram-ui.trainer-personal-shell.theme-dark .profile-box p,
.telegram-ui.trainer-personal-shell.theme-dark .profile-box span,
.telegram-ui.trainer-personal-shell.theme-dark .library-row strong,
.telegram-ui.trainer-personal-shell.theme-dark .report-row strong,
.telegram-ui.trainer-personal-shell.theme-dark .progress-history-row strong,
.telegram-ui.trainer-personal-shell.theme-dark .progress-history-row span{
  color:#f3f6f8!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .library-row small,
.telegram-ui.trainer-personal-shell.theme-dark .report-row small,
.telegram-ui.trainer-personal-shell.theme-dark .profile-box small{
  color:#aebdca!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .library-status{
  background:rgba(111,140,164,.22)!important;
  color:#c8d6e0!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .library-status-warning{
  background:rgba(176,112,31,.22)!important;
  color:#ffc66d!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .library-tabs{
  background:rgba(38,52,64,.62);
  border-color:rgba(157,181,200,.14);
}
.telegram-ui.trainer-personal-shell.theme-dark .library-tab{
  color:#aebdca!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .library-tab.is-active{
  color:#fff!important;
}

/* Ensure all checkbox pills inside the preference page inherit a dark surface,
   including compact Ban/Prefer buttons. */
.telegram-ui.trainer-personal-shell.theme-dark .exercise-pref-row .check,
.telegram-ui.theme-dark .exercise-pref-row .check{
  background:rgba(30,43,54,.88)!important;
  border:1px solid rgba(157,181,200,.16)!important;
  color:#f3f6f8!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .exercise-pref-row .check:has(input:checked),
.telegram-ui.theme-dark .exercise-pref-row .check:has(input:checked){
  background:color-mix(in srgb,var(--tg-blue) 24%,#202b36)!important;
  border-color:color-mix(in srgb,var(--tg-blue) 55%,#405160)!important;
}

@media(prefers-color-scheme:dark){
  .telegram-ui.theme-system .exercise-pref-row{
    background:rgba(38,52,64,.82)!important;
    border:1px solid rgba(157,181,200,.14)!important;
    color:#f3f6f8!important;
  }
  .telegram-ui.theme-system .exercise-pref-row strong,
  .telegram-ui.theme-system .exercise-pref-row label{color:#f3f6f8!important}
  .telegram-ui.theme-system .exercise-pref-row small{color:#aebdca!important}
  .telegram-ui.theme-system .library-tabs{background:rgba(38,52,64,.62)}
  .telegram-ui.theme-system .library-status{background:rgba(111,140,164,.22);color:#c8d6e0}
}

@media(max-width:700px){
  .library-tabs{width:100%}
  .library-tab{flex:1 0 auto;text-align:center}
  .library-block-row{grid-template-columns:minmax(0,1fr) auto}
  .library-block-row form{grid-column:1/-1}
  .library-block-row form button{width:100%}
}


/* =========================================================
   Stage 3.14.2 — Automatic personal block classification
   ========================================================= */
.auto-block-summary{
  display:flex;
  flex-direction:column;
  gap:4px;
  min-height:58px;
  padding:11px 13px;
  border:1px solid var(--tg-line,#e7ebef);
  border-radius:10px;
  background:rgba(51,144,236,.06);
}
.auto-block-summary strong{
  color:var(--tg-blue,#3390ec);
  font-size:13px;
}
.auto-block-summary small{
  color:var(--tg-muted,#708499);
  font-size:10px;
}
.telegram-ui.theme-dark .auto-block-summary,
.telegram-ui.trainer-personal-shell.theme-dark .auto-block-summary{
  background:rgba(64,126,181,.14);
  border-color:rgba(125,165,198,.20);
}
.telegram-ui.theme-dark .auto-block-summary strong,
.telegram-ui.trainer-personal-shell.theme-dark .auto-block-summary strong{
  color:#7bc0f8!important;
}
.telegram-ui.theme-dark .auto-block-summary small,
.telegram-ui.trainer-personal-shell.theme-dark .auto-block-summary small{
  color:#b6c4cf!important;
}

/* =========================================================
   Stage 3.15.0 — Trainer history clarity + working weights
   ========================================================= */

/* Athlete quick tools */
.athlete-tools-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:9px;
}
.athlete-tools-grid .athlete-history-link{
  margin:0;
  min-width:0;
}
.athlete-working-link .history-link-icon{
  font-size:10px;
  font-weight:900;
  text-transform:uppercase;
}

/* Change history: clearer timeline instead of visually flat rows. */
.change-history-wrap{
  margin:14px 13px 13px;
  padding:13px;
  border:1px solid rgba(120,145,165,.16);
  border-radius:13px;
  background:rgba(247,249,251,.88);
}
.change-history-title{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  padding-bottom:10px;
  border-bottom:1px solid rgba(120,145,165,.15);
}
.change-history-title>span{
  font-size:13px;
  font-weight:850;
}
.change-history-title>small{
  color:var(--tg-muted,#708499);
  font-size:9px;
}
.change-history-section{
  padding-top:12px;
}
.change-history-section h3{
  margin:0 0 7px;
  font-size:11px;
  color:var(--tg-muted,#708499);
  text-transform:uppercase;
  letter-spacing:.035em;
}
.change-event-list{
  display:grid;
  gap:0;
  overflow:hidden;
  border-radius:10px;
  border:1px solid rgba(120,145,165,.13);
  background:#fff;
}
.change-event{
  position:relative;
  display:grid;
  grid-template-columns:10px minmax(0,1fr) auto;
  align-items:center;
  gap:10px;
  min-height:50px;
  padding:9px 11px;
  border-bottom:1px solid rgba(120,145,165,.12);
  color:#17212b;
  text-decoration:none;
  background:#fff;
}
.change-event:last-child{border-bottom:0}
a.change-event:hover{background:#f7f9fb}
.change-event-dot{
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--tg-blue,#3390ec);
  box-shadow:0 0 0 3px color-mix(in srgb,var(--tg-blue,#3390ec) 12%,transparent);
}
.change-event-copy{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
}
.change-event-copy strong{
  font-size:11px;
  line-height:1.25;
}
.change-event-copy span{
  color:var(--tg-muted,#708499);
  font-size:9px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.change-event time{
  color:var(--tg-muted,#708499);
  font-size:9px;
  white-space:nowrap;
}

/* Dedicated workout history page */
.workout-history-page{
  max-width:860px;
}
.history-summary,
.working-summary{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:1px;
  overflow:hidden;
  margin-bottom:10px;
  border-radius:12px;
  background:rgba(120,145,165,.14);
}
.history-summary{
  grid-template-columns:repeat(2,minmax(0,1fr));
}
.history-summary>div,
.working-summary>div{
  min-width:0;
  padding:11px 13px;
  background:rgba(255,255,255,.94);
}
.history-summary span,
.working-summary span{
  display:block;
  color:var(--tg-muted,#708499);
  font-size:9px;
  margin-bottom:3px;
}
.history-summary strong,
.working-summary strong{
  display:block;
  font-size:14px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.history-section{
  overflow:hidden;
  border-radius:13px;
  background:rgba(255,255,255,.96);
  box-shadow:0 1px 3px rgba(23,33,43,.06);
}
.history-section-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:13px 14px 9px;
  border-bottom:1px solid rgba(120,145,165,.13);
}
.history-section-head h2{margin:2px 0 0}
.history-count{
  min-width:28px;
  height:28px;
  padding:0 7px;
  display:grid;
  place-items:center;
  border-radius:999px;
  background:var(--tg-blue-soft,#eaf4ff);
  color:var(--tg-blue,#3390ec);
  font-size:10px;
  font-weight:850;
}
.workout-history-page .history-workout-list{
  gap:0;
  border-radius:0;
  box-shadow:none;
}
.workout-history-page .history-workout-row{
  display:grid;
  grid-template-columns:43px minmax(0,1fr) auto 16px;
  align-items:center;
  gap:11px;
  padding:10px 13px;
  border-bottom:1px solid rgba(120,145,165,.12);
}
.workout-history-page .history-workout-row:last-child{border-bottom:0}
.history-date-badge{
  width:40px;
  height:44px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  border-radius:10px;
  background:#f1f6fa;
  color:#52687a;
  line-height:1;
}
.history-date-badge strong{font-size:15px}
.history-date-badge small{margin-top:4px;font-size:8px}
.history-cycle-label{
  display:block;
  margin-bottom:2px;
  color:var(--tg-blue,#3390ec)!important;
  font-size:8.5px!important;
  font-weight:800;
}
.history-other-details{
  margin-top:10px;
  overflow:hidden;
  border-radius:12px;
  background:rgba(255,255,255,.90);
}
.history-other-details>summary{
  padding:11px 13px;
  cursor:pointer;
  font-size:10px;
  font-weight:800;
  color:var(--tg-muted,#708499);
}

/* Working weights trainer reference */
.working-weights-page{
  max-width:900px;
  margin:0 auto;
}
.working-tabs{
  display:flex;
  gap:4px;
  margin:10px 0;
  padding:4px;
  border-radius:11px;
  background:rgba(255,255,255,.87);
  box-shadow:0 1px 3px rgba(23,33,43,.05);
}
.working-tabs a{
  flex:1;
  min-height:37px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:8px;
  color:var(--tg-muted,#708499);
  text-decoration:none;
  font-size:11px;
  font-weight:800;
}
.working-tabs a.is-active{
  background:var(--tg-blue,#3390ec);
  color:#fff!important;
}
.working-reference-list{
  display:grid;
  gap:9px;
}
.working-reference-card{
  overflow:hidden;
  border-radius:13px;
  background:rgba(255,255,255,.96);
  box-shadow:0 1px 3px rgba(23,33,43,.06);
}
.working-reference-head{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:14px;
  padding:13px 14px 10px;
}
.working-reference-head h2{
  margin:2px 0 0;
  font-size:16px;
}
.working-reference-head p{
  margin:4px 0 0;
  font-size:10px;
}
.working-latest{
  min-width:110px;
  text-align:right;
}
.working-latest span,
.working-latest small{
  display:block;
  color:var(--tg-muted,#708499);
  font-size:8.5px;
}
.working-latest strong{
  display:block;
  margin:2px 0;
  font-size:15px;
}
.working-latest-sets{
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  gap:10px;
  align-items:center;
  margin:0 14px 10px;
  padding:9px 10px;
  border-radius:9px;
  background:#f4f8fb;
}
.working-latest-sets span{
  color:var(--tg-muted,#708499);
  font-size:9px;
}
.working-latest-sets strong{
  text-align:right;
  font-size:11px;
}
.working-history-details{
  border-top:1px solid rgba(120,145,165,.13);
}
.working-history-details>summary{
  padding:9px 14px;
  cursor:pointer;
  color:var(--tg-muted,#708499);
  font-size:9.5px;
  font-weight:800;
}
.working-history-list{
  border-top:1px solid rgba(120,145,165,.10);
}
.working-history-row{
  display:grid;
  grid-template-columns:82px minmax(0,1fr) 14px;
  align-items:center;
  gap:10px;
  min-height:52px;
  padding:8px 14px;
  border-bottom:1px solid rgba(120,145,165,.10);
  color:#17212b;
  text-decoration:none;
}
.working-history-row:last-child{border-bottom:0}
.working-history-row:hover{background:#f7f9fb}
.working-history-date{
  color:var(--tg-muted,#708499);
  font-size:9px;
}
.working-history-session{
  min-width:0;
}
.working-history-session strong{
  display:block;
  font-size:11px;
}
.working-history-session small{
  display:block;
  margin-top:3px;
  color:var(--tg-muted,#708499);
  font-size:8.5px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.working-block-session-list{
  border-top:1px solid rgba(120,145,165,.10);
}
.working-block-session{
  display:block;
  padding:10px 14px;
  border-bottom:1px solid rgba(120,145,165,.11);
  color:#17212b;
  text-decoration:none;
}
.working-block-session:last-child{border-bottom:0}
.working-block-session:hover{background:#f7f9fb}
.working-block-session-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:7px;
}
.working-block-session-head strong{font-size:10px}
.working-block-session-head small{
  color:var(--tg-muted,#708499);
  font-size:8.5px;
}
.block-weight-lines{
  display:grid;
  gap:5px;
}
.block-weight-line{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:10px;
  align-items:center;
  padding:6px 8px;
  border-radius:8px;
  background:#f4f8fb;
}
.block-weight-line span{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#52687a;
  font-size:9px;
}
.block-weight-line strong{
  font-size:10px;
}

/* Progress now links out to dedicated training-data tools. */
.progress-tools-card{margin-top:10px}
.progress-tool-links{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
}
.progress-tool-links a{
  position:relative;
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:3px 10px;
  padding:11px 12px;
  border-radius:10px;
  background:#f4f8fb;
  color:#17212b;
  text-decoration:none;
}
.progress-tool-links a strong{font-size:11px}
.progress-tool-links a span{
  grid-column:1;
  color:var(--tg-muted,#708499);
  font-size:8.5px;
}
.progress-tool-links a b{
  grid-column:2;
  grid-row:1/3;
  align-self:center;
  color:var(--tg-blue,#3390ec);
  font-size:19px;
}

/* Dark trainer/client support */
.telegram-ui.theme-dark .change-history-wrap,
.telegram-ui.theme-dark .history-section,
.telegram-ui.theme-dark .history-other-details,
.telegram-ui.theme-dark .working-tabs,
.telegram-ui.theme-dark .working-reference-card{
  background:rgba(32,43,54,.91)!important;
  border-color:rgba(157,181,200,.13)!important;
  color:#f3f6f8!important;
}
.telegram-ui.theme-dark .change-event-list,
.telegram-ui.theme-dark .change-event,
.telegram-ui.theme-dark .history-summary>div,
.telegram-ui.theme-dark .working-summary>div{
  background:rgba(38,52,64,.88)!important;
  border-color:rgba(157,181,200,.12)!important;
  color:#f3f6f8!important;
}
.telegram-ui.theme-dark a.change-event:hover,
.telegram-ui.theme-dark .working-history-row:hover,
.telegram-ui.theme-dark .working-block-session:hover{
  background:rgba(53,69,82,.92)!important;
}
.telegram-ui.theme-dark .change-event-copy span,
.telegram-ui.theme-dark .change-event time,
.telegram-ui.theme-dark .change-history-title>small,
.telegram-ui.theme-dark .history-summary span,
.telegram-ui.theme-dark .working-summary span,
.telegram-ui.theme-dark .working-latest span,
.telegram-ui.theme-dark .working-latest small,
.telegram-ui.theme-dark .working-history-date,
.telegram-ui.theme-dark .working-history-session small,
.telegram-ui.theme-dark .working-block-session-head small,
.telegram-ui.theme-dark .block-weight-line span{
  color:#aebdca!important;
}
.telegram-ui.theme-dark .history-date-badge,
.telegram-ui.theme-dark .working-latest-sets,
.telegram-ui.theme-dark .block-weight-line,
.telegram-ui.theme-dark .progress-tool-links a{
  background:rgba(38,52,64,.80)!important;
  color:#f3f6f8!important;
}
.telegram-ui.theme-dark .working-history-row,
.telegram-ui.theme-dark .working-block-session{
  color:#f3f6f8!important;
  border-color:rgba(157,181,200,.11)!important;
}
.telegram-ui.theme-dark .working-history-session strong,
.telegram-ui.theme-dark .block-weight-line strong,
.telegram-ui.theme-dark .working-reference-head h2,
.telegram-ui.theme-dark .working-latest strong,
.telegram-ui.theme-dark .progress-tool-links a strong{
  color:#f5f8fa!important;
}

@media(max-width:700px){
  .athlete-tools-grid{grid-template-columns:1fr}
  .history-summary,.working-summary{grid-template-columns:repeat(2,minmax(0,1fr))}
  .workout-history-page .history-workout-row{
    grid-template-columns:38px minmax(0,1fr) 14px;
    gap:8px;
    padding:9px 10px;
  }
  .workout-history-page .history-workout-meta{
    grid-column:2;
    flex-direction:row;
    align-items:center;
    justify-content:flex-start;
  }
  .workout-history-page .history-workout-row>.row-chevron{
    grid-column:3;
    grid-row:1/3;
  }
  .history-date-badge{width:36px;height:40px}
  .working-reference-head{padding:11px 12px 9px}
  .working-reference-head h2{font-size:14px}
  .working-latest{min-width:96px}
  .working-latest strong{font-size:13px}
  .working-history-row{grid-template-columns:68px minmax(0,1fr) 12px;padding:8px 12px}
  .working-latest-sets{grid-template-columns:1fr;margin:0 12px 9px}
  .working-latest-sets strong{text-align:left}
  .progress-tool-links{grid-template-columns:1fr}
  .change-history-title{align-items:flex-start;flex-direction:column;gap:2px}
  .change-event{grid-template-columns:8px minmax(0,1fr);gap:8px}
  .change-event time{grid-column:2}
}
.working-filter-wrap{margin:0 0 9px}
.working-filter{
  min-height:40px;
  border-radius:10px!important;
  background:rgba(255,255,255,.92)!important;
}
.working-reference-card[hidden]{display:none!important}
.telegram-ui.theme-dark .working-filter{
  background:rgba(32,43,54,.92)!important;
  color:#f3f6f8!important;
  border-color:rgba(157,181,200,.16)!important;
}

/* Histories of measurements / exercise progress read as dated events. */
.telegram-ui .progress-history-row{
  position:relative;
  border-left:3px solid color-mix(in srgb,var(--tg-blue,#3390ec) 55%,transparent)!important;
}
.telegram-ui .progress-history-row>span:first-child{
  font-weight:800;
  color:#52687a;
}
.telegram-ui.theme-dark .progress-history-row>span:first-child{
  color:#dce7ee!important;
}

/* =========================================================
   Stage 3.16.0 — Optional trainer load recommendations
   ========================================================= */
.load-history-hint{
  margin-top:7px;padding:7px 9px;border-radius:9px;
  background:rgba(51,144,236,.08);display:grid;grid-template-columns:auto 1fr auto;
  align-items:center;gap:6px 9px;font-size:10px;
}
.load-history-hint span{color:var(--tg-muted,#708499)}
.load-history-hint strong{font-size:11px;min-width:0}
.load-history-hint small{font-size:9px;white-space:nowrap}
.load-history-hint.is-empty{grid-template-columns:auto 1fr;background:rgba(112,132,148,.07)}

.trainer-recommendation-editor{
  margin-top:8px;border:1px solid rgba(120,145,165,.18);border-radius:10px;
  background:rgba(255,255,255,.44);overflow:hidden;
}
.trainer-recommendation-editor>summary{
  list-style:none;cursor:pointer;padding:9px 10px;color:var(--tg-blue);
  font-size:11px;font-weight:800;
}
.trainer-recommendation-editor>summary::-webkit-details-marker{display:none}
.trainer-recommendation-editor[open]>summary{border-bottom:1px solid rgba(120,145,165,.14)}
.trainer-recommendation-editor form{padding:10px}
.recommendation-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.recommendation-fields label{min-width:0}
.recommendation-fields .wide{grid-column:1/-1}
.recommendation-fields input{min-width:0}
.recommendation-actions{display:flex;gap:7px;flex-wrap:wrap;margin-top:9px}

.program-exercise-line{display:grid;gap:5px}
.program-load-recommendation,
.workout-load-recommendation{
  display:flex;flex-wrap:wrap;align-items:center;gap:5px 8px;
  width:max-content;max-width:100%;padding:6px 8px;border-radius:9px;
  background:var(--tg-blue-soft,rgba(51,144,236,.12));
  color:inherit;
}
.program-load-recommendation span,
.workout-load-recommendation span{
  color:var(--tg-blue);font-size:9px;font-weight:800;text-transform:uppercase;letter-spacing:.025em;
}
.program-load-recommendation strong,
.workout-load-recommendation strong{font-size:11px;color:inherit!important}
.workout-load-recommendation{margin:8px 0 10px;width:auto}
.workout-load-recommendation small{flex-basis:100%;font-size:9px;color:var(--tg-muted,#708499)!important}

.telegram-ui.trainer-personal-shell.theme-dark .load-history-hint,
.telegram-ui.theme-dark .load-history-hint{
  background:rgba(61,100,132,.24)!important;
  color:#f3f6f8!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .trainer-recommendation-editor,
.telegram-ui.theme-dark .trainer-recommendation-editor{
  background:rgba(38,52,64,.70)!important;
  border-color:rgba(157,181,200,.16)!important;
}
.telegram-ui.trainer-personal-shell.theme-dark .trainer-recommendation-editor[open]>summary,
.telegram-ui.theme-dark .trainer-recommendation-editor[open]>summary{
  border-color:rgba(157,181,200,.14)!important;
}
.telegram-ui.theme-dark .program-load-recommendation,
.telegram-ui.theme-dark .workout-load-recommendation{
  background:rgba(69,117,159,.22)!important;
  color:#f3f6f8!important;
}
.telegram-ui.theme-dark .workout-load-recommendation small{color:#b6c4cf!important}

@media(max-width:700px){
  .draft-load-row{gap:10px}
  .load-history-hint{grid-template-columns:1fr auto}
  .load-history-hint span{grid-column:1/-1}
  .recommendation-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
  .recommendation-actions{flex-direction:column}
  .recommendation-actions button{width:100%}
}
@media(max-width:390px){
  .recommendation-fields{grid-template-columns:1fr}
  .recommendation-fields .wide{grid-column:auto}
}


/* =========================================================
   Stage 3.16.1 — Clean exercise base + personal muscle groups
   ========================================================= */
.library-muscle-row{grid-template-columns:minmax(0,1fr) auto auto}
.library-muscle-row small{display:block;margin-top:3px}
@media(max-width:700px){
  .library-muscle-row{grid-template-columns:minmax(0,1fr) auto}
  .library-muscle-row form{grid-column:1/-1}
  .library-muscle-row form button{width:100%}
}


/* Stage 3.16.2 — trainer-owned exercise sets */
.library-empty-system-sets{padding:14px 16px}
.library-empty-system-sets strong{display:block;margin-bottom:3px}


/* Stage 3.17.0 — pilot account security */
.account-settings-page{max-width:760px;margin:0 auto}
.account-security-form{margin-top:14px}
.account-current-row b{font-size:13px;overflow-wrap:anywhere}
.telegram-ui.theme-dark .account-current-row b{color:#f3f6f8}
.setup-owner-link{margin-top:14px;text-align:center}


/* =========================================================
   Stage 3.17.1 — Trainer / Owner profile avatars
   ========================================================= */
.trainer-avatar-settings .settings-avatar-row{display:flex;align-items:center;gap:14px;margin:12px 0 15px}
.trainer-avatar-settings .settings-avatar-row>div:last-child{display:flex;flex-direction:column;gap:4px;min-width:0}
.trainer-avatar-settings .settings-avatar-row small{color:var(--tg-muted,#708499)}
.trainer-admin-card{display:grid;gap:12px}
.trainer-admin-head{display:flex;align-items:center;gap:12px}
.trainer-admin-head h2{margin:0 0 4px}
.trainer-admin-head p{margin:2px 0}
.trainer-admin-avatar,.client-trainer-avatar{width:54px;height:54px;flex:0 0 54px;border-radius:50%;display:grid;place-items:center;overflow:hidden;background:linear-gradient(145deg,var(--accent-start,#75c3f5),var(--accent-end,#3390ec));color:#fff;font-weight:850}
.trainer-admin-avatar img,.client-trainer-avatar img{width:100%;height:100%;display:block;object-fit:cover}
.trainer-avatar-admin-form{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;align-items:center}
.trainer-avatar-admin-form input[type=file]{min-height:40px}
.client-trainer-card{display:flex;align-items:center;justify-content:space-between;gap:12px}
.client-trainer-profile{display:flex;align-items:center;gap:12px;min-width:0}
.client-trainer-profile>div{display:flex;flex-direction:column;gap:3px;min-width:0}
.client-trainer-profile strong{font-size:15px}
.client-trainer-profile small{color:var(--tg-muted,#708499);font-size:10px}
.telegram-ui.theme-dark .trainer-avatar-admin-form input[type=file]{background:rgba(38,52,64,.82);color:#f3f6f8;border-color:rgba(157,181,200,.18)}
@media(max-width:650px){.client-trainer-card{align-items:stretch;flex-direction:column}.client-trainer-card>.button{width:100%;text-align:center}.trainer-avatar-admin-form{grid-template-columns:1fr}.trainer-avatar-admin-form button{width:100%}}


/* =========================================================
   Stage 3.17.2 — True circular avatars + full-size viewer
   ========================================================= */
.trainer-avatar-settings .settings-avatar-row{
  align-items:center;
}
.avatar-preview-button{
  width:82px;
  height:82px;
  flex:0 0 82px;
  padding:0!important;
  margin:0;
  border:0!important;
  border-radius:50%!important;
  overflow:hidden;
  background:transparent!important;
  box-shadow:none!important;
  display:block;
  cursor:zoom-in;
}
.avatar-preview-button .settings-avatar-image{
  width:100%;
  height:100%;
  display:block;
  border-radius:50%;
  object-fit:cover;
  object-position:center;
}
.trainer-avatar-settings .settings-avatar-placeholder{
  width:82px;
  height:82px;
  flex:0 0 82px;
}
[data-avatar-preview]{cursor:zoom-in}
.avatar-lightbox[hidden]{display:none!important}
.avatar-lightbox{
  position:fixed;
  inset:0;
  z-index:5000;
  display:grid;
  place-items:center;
  padding:28px;
  background:rgba(7,12,17,.88);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
}
.avatar-lightbox-stage{
  width:min(88vw,720px);
  height:min(82vh,720px);
  display:grid;
  place-items:center;
}
.avatar-lightbox-stage img{
  display:block;
  max-width:100%;
  max-height:100%;
  width:auto;
  height:auto;
  object-fit:contain;
  border-radius:14px;
  box-shadow:0 18px 70px rgba(0,0,0,.45);
}
.avatar-lightbox-close{
  position:fixed;
  top:max(14px,env(safe-area-inset-top));
  right:max(14px,env(safe-area-inset-right));
  width:42px;
  height:42px;
  min-height:42px;
  padding:0!important;
  border-radius:50%!important;
  background:rgba(255,255,255,.14)!important;
  color:#fff!important;
  font-size:28px;
  line-height:1;
  display:grid;
  place-items:center;
}
body.avatar-lightbox-open{overflow:hidden}
@media(max-width:650px){
  .avatar-preview-button,
  .trainer-avatar-settings .settings-avatar-placeholder{width:72px;height:72px;flex-basis:72px}
  .avatar-lightbox{padding:16px}
  .avatar-lightbox-stage{width:94vw;height:80vh}
}


/* =========================================================
   Stage 3.17.3 — Athlete actions menu viewport alignment
   ========================================================= */
/* The athlete card sits inside a wallpaper shell with overflow clipping.
   A wide popup right-aligned to the small "Действия" button could therefore
   extend past the shell's left edge and lose the first letters. Alignment is
   now chosen at runtime based on available space. */
.athlete-actions-menu[data-popup-align="left"] .action-menu-panel{
  left:0 !important;
  right:auto !important;
}
.athlete-actions-menu[data-popup-align="right"] .action-menu-panel{
  left:auto !important;
  right:0 !important;
}
.athlete-actions-menu .action-menu-panel{
  box-sizing:border-box;
  overflow:visible;
}
.athlete-actions-menu .action-menu-panel a,
.athlete-actions-menu .action-menu-panel button{
  overflow:visible;
  white-space:normal;
}

/* =========================================================
   Stage 3.17.4 — cycle archive / delete management
   ========================================================= */
.danger-button{
  background:#dc2626!important;
  color:#fff!important;
}
.danger-button:hover{background:#b91c1c!important;color:#fff!important}
.cycle-archive-section{display:grid;gap:10px}
.cycle-archive-section h2{margin:0 0 4px}
.cycle-archive-row{
  display:flex;align-items:center;justify-content:space-between;gap:14px;
  padding:12px 0;border-bottom:1px solid var(--tg-line,#e7ebef);
}
.cycle-archive-row:last-child{border-bottom:0}
.cycle-archive-copy{display:flex;flex-direction:column;gap:3px;min-width:0}
.cycle-archive-copy strong{font-size:13px}
.cycle-archive-copy span{font-size:10px;color:var(--tg-muted,#708499)}
.cycle-archive-actions{display:flex;align-items:center;justify-content:flex-end;gap:7px;flex-wrap:wrap}
.cycle-archive-actions form{display:inline;margin:0}
.cycle-archive-actions button{min-height:34px;padding:7px 10px;font-size:10px}
.telegram-ui.theme-dark .cycle-archive-row{border-color:rgba(154,178,196,.16)}
.telegram-ui.theme-dark .cycle-archive-copy span{color:#aebdca}
@media(max-width:700px){
  .cycle-archive-row{align-items:flex-start;flex-direction:column}
  .cycle-archive-actions{justify-content:flex-start;width:100%}
}

/* =========================================================
   Stage 3.17.5 — Workout access + grouped exercise catalogue
   ========================================================= */
.workout-access-manager{margin-bottom:12px}
.workout-access-manage-list{display:grid;gap:8px}
.workout-access-manage-row{
  display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center;
  padding:11px 12px;border:1px solid var(--fc-border-soft,#e5e7eb);border-radius:11px;
  background:var(--fc-surface-soft,#f8fafc);
}
.workout-access-manage-row strong{display:block;font-size:13px}
.workout-access-manage-row small{display:block;margin-top:3px;color:var(--fc-muted,#6b7280);font-size:10px}
.access-state{font-size:11px;font-weight:750;color:var(--fc-muted,#6b7280)}
.access-completed{color:var(--fc-green,#15803d)}
.workout-access-locked{cursor:default;opacity:.84}
.workout-access-locked strong{color:inherit}
.workout-access-locked span{color:var(--fc-muted,#6b7280)!important}
.workout-access-open span{color:var(--fc-green,#15803d)!important;font-weight:750}
.workout-access-waiting{border-left:4px solid var(--tg-blue,#3390ec)}
.client-program-access-overview{max-width:760px}

.library-add-exercise details>summary,
.library-catalogue-card h2,
.library-catalogue-card h3{cursor:default}
.library-add-exercise details>summary,
.library-catalogue-card+section.card details>summary{
  list-style:none;cursor:pointer;font-weight:800;color:var(--tg-blue,#3390ec)
}
.library-add-exercise details>summary::-webkit-details-marker,
.library-catalogue-card+section.card details>summary::-webkit-details-marker{display:none}
.library-add-exercise details[open]>summary{margin-bottom:14px}
.library-catalogue-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:12px}
.library-catalogue-head h2{margin:0 0 4px}
.library-catalogue-head p{margin:0}
.library-filter-bar{
  display:grid;grid-template-columns:minmax(210px,1.5fr) repeat(3,minmax(145px,1fr)) auto;
  gap:8px;align-items:end;margin-bottom:12px;padding:12px;border-radius:12px;
  background:var(--fc-surface-soft,#f8fafc);
}
.library-filter-bar label{font-size:10px;color:var(--fc-muted,#6b7280)}
.library-filter-bar input,.library-filter-bar select{min-height:40px}
.library-filter-bar button{min-height:40px}
.library-muscle-chips{display:flex;gap:6px;overflow-x:auto;padding:2px 1px 10px;scrollbar-width:thin}
.library-muscle-chip{
  flex:0 0 auto;display:inline-flex;align-items:center;gap:6px;padding:7px 10px;border-radius:999px;
  background:var(--fc-surface-soft,#f3f4f6);color:var(--fc-text,#111827)!important;text-decoration:none;
  font-size:11px;font-weight:750;border:1px solid var(--fc-border-soft,#e5e7eb)
}
.library-muscle-chip span{display:inline-grid;place-items:center;min-width:19px;height:19px;padding:0 5px;border-radius:999px;background:rgba(127,145,160,.12);font-size:9px}
.library-muscle-chip.is-active{background:var(--tg-blue-soft,rgba(51,144,236,.12));border-color:rgba(51,144,236,.28);color:var(--tg-blue,#3390ec)!important}
.library-catalogue-groups{display:grid;gap:14px}
.library-muscle-section{border:1px solid var(--fc-border-soft,#e5e7eb);border-radius:12px;overflow:hidden}
.library-muscle-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 12px;background:var(--fc-surface-soft,#f8fafc);border-bottom:1px solid var(--fc-border-soft,#e5e7eb)}
.library-muscle-heading h3{margin:0;font-size:14px}
.library-muscle-heading span{font-size:10px;color:var(--fc-muted,#6b7280)}
.library-catalogue-list{display:grid;gap:0}
.library-catalogue-row{
  display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:10px;
  min-height:58px;padding:9px 12px;border-bottom:1px solid var(--fc-border-soft,#eef1f4);
  background:#fff
}
.library-catalogue-row:last-child{border-bottom:0}
.library-catalogue-main{min-width:0}
.library-catalogue-main strong{display:block;font-size:12px;margin-bottom:3px}
.library-catalogue-main small{display:block;color:var(--fc-muted,#6b7280);font-size:9.5px;line-height:1.35}
.library-filter-empty{text-align:center;padding:28px 16px;border:1px dashed var(--fc-border,#d1d5db);border-radius:12px}
.library-filter-empty p{margin:5px 0 0}
.library-archive-list{margin-top:12px}

.telegram-ui.trainer-personal-shell.theme-dark .workout-access-manage-row,
.telegram-ui.theme-dark .workout-access-manage-row,
.telegram-ui.trainer-personal-shell.theme-dark .library-filter-bar,
.telegram-ui.theme-dark .library-filter-bar,
.telegram-ui.trainer-personal-shell.theme-dark .library-muscle-heading,
.telegram-ui.theme-dark .library-muscle-heading{
  background:rgba(38,52,64,.72)!important;border-color:rgba(155,180,200,.16)!important
}
.telegram-ui.trainer-personal-shell.theme-dark .library-muscle-section,
.telegram-ui.theme-dark .library-muscle-section{border-color:rgba(155,180,200,.16)!important}
.telegram-ui.trainer-personal-shell.theme-dark .library-catalogue-row,
.telegram-ui.theme-dark .library-catalogue-row{
  background:rgba(32,43,54,.78)!important;border-color:rgba(155,180,200,.12)!important;color:#f3f6f8!important
}
.telegram-ui.trainer-personal-shell.theme-dark .library-catalogue-main strong,
.telegram-ui.theme-dark .library-catalogue-main strong{color:#f3f6f8!important}
.telegram-ui.trainer-personal-shell.theme-dark .library-catalogue-main small,
.telegram-ui.theme-dark .library-catalogue-main small,
.telegram-ui.trainer-personal-shell.theme-dark .workout-access-manage-row small,
.telegram-ui.theme-dark .workout-access-manage-row small{color:#b6c4cf!important}
.telegram-ui.trainer-personal-shell.theme-dark .library-muscle-chip,
.telegram-ui.theme-dark .library-muscle-chip{
  background:rgba(38,52,64,.78)!important;border-color:rgba(155,180,200,.16)!important;color:#f3f6f8!important
}
.telegram-ui.trainer-personal-shell.theme-dark .library-muscle-chip.is-active,
.telegram-ui.theme-dark .library-muscle-chip.is-active{color:var(--tg-blue)!important;background:var(--tg-blue-soft)!important}

@media(max-width:900px){
  .library-filter-bar{grid-template-columns:1fr 1fr}
  .library-search{grid-column:1/-1}
  .library-filter-bar button{width:100%}
}
@media(max-width:620px){
  .workout-access-manage-row{grid-template-columns:1fr}
  .workout-access-manage-row form,.workout-access-manage-row button{width:100%}
  .library-filter-bar{grid-template-columns:1fr}
  .library-search{grid-column:auto}
  .library-catalogue-row{grid-template-columns:minmax(0,1fr) auto}
  .library-catalogue-row form{grid-column:1/-1;width:100%}
  .library-catalogue-row form button{width:100%}
  .library-catalogue-head{flex-direction:column}
}

/* =========================================================
   Stage 3.17.6 — Draft drag/drop + simpler generation structure
   ========================================================= */
.draft-arrange-panel{
  margin:14px 0 16px;padding:12px;border:1px solid var(--fc-border-soft,#e5e7eb);
  border-radius:12px;background:var(--fc-surface-soft,#f8fafc)
}
.draft-arrange-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:10px}
.draft-arrange-head h3{margin:0 0 3px;font-size:14px}
.draft-save-state{flex:0 0 auto;padding:5px 8px;border-radius:999px;background:rgba(127,145,160,.10);font-size:9px;font-weight:800;color:var(--fc-muted,#6b7280)}
.draft-save-state[data-state="saving"]{color:var(--tg-blue,#3390ec)}
.draft-save-state[data-state="ok"]{color:var(--fc-green,#15803d);background:rgba(34,197,94,.10)}
.draft-save-state[data-state="error"]{color:#dc2626;background:rgba(220,38,38,.10)}
.draft-sort-board{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:9px;align-items:start}
.draft-sort-day{min-width:0;border:1px solid var(--fc-border-soft,#e5e7eb);border-radius:11px;background:#fff;overflow:hidden}
.draft-sort-day-head{padding:9px 10px;border-bottom:1px solid var(--fc-border-soft,#e5e7eb);background:rgba(127,145,160,.055)}
.draft-sort-day-head strong{display:block;font-size:11px}
.draft-sort-day-head small{display:block;margin-top:2px;font-size:8.5px;color:var(--fc-muted,#6b7280)}
.draft-sort-list{min-height:50px;padding:7px;display:grid;gap:6px;transition:.15s ease}
.draft-sort-list.is-dragover{background:var(--tg-blue-soft,rgba(51,144,236,.10))}
.draft-sort-item{
  display:grid;grid-template-columns:24px minmax(0,1fr);gap:7px;align-items:center;
  padding:8px 9px;border:1px solid var(--fc-border-soft,#e5e7eb);border-radius:9px;
  background:#fff;cursor:grab;user-select:none;box-shadow:0 1px 2px rgba(15,23,42,.03)
}
.draft-sort-item:active{cursor:grabbing}
.draft-sort-item.is-dragging{opacity:.42;transform:scale(.985)}
.draft-drag-handle{font-size:18px;line-height:1;color:var(--fc-muted,#94a3b8);letter-spacing:-5px;transform:translateX(-2px)}
.draft-sort-copy{min-width:0;display:flex;flex-direction:column;gap:2px}
.draft-sort-copy small{font-size:8px;text-transform:uppercase;letter-spacing:.04em;color:var(--tg-blue,#3390ec);font-weight:850}
.draft-sort-copy strong{font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.draft-sort-copy span{font-size:8.5px;color:var(--fc-muted,#6b7280);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.structure-starter{
  display:flex;align-items:center;justify-content:space-between;gap:10px;margin:8px 0 12px;padding:11px 12px;
  border:1px dashed var(--fc-border,#cbd5e1);border-radius:11px;background:var(--fc-surface-soft,#f8fafc)
}
.structure-starter[hidden]{display:none!important}
.structure-starter>span{font-size:11px;font-weight:800;color:var(--fc-muted,#64748b)}
.structure-starter>div{display:flex;gap:7px;flex-wrap:wrap}
.structure-row{position:relative;margin:8px 0!important;padding:12px!important}
.structure-row-head{align-items:center!important;margin-bottom:9px!important}
.structure-row-head>label{flex:1;min-width:180px!important}
.structure-row-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.structure-row-actions button{min-height:34px;padding:7px 9px;font-size:10px}
.structure-below-actions{
  display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap;
  margin-top:10px;padding-top:9px;border-top:1px solid var(--fc-border-soft,#e5e7eb)
}
.structure-below-actions>span{margin-right:auto;font-size:9px;color:var(--fc-muted,#6b7280);font-weight:750}
.structure-below-actions button{min-height:32px;padding:6px 9px;font-size:9.5px}
.structure-details.form-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.structure-details .wide{grid-column:1/-1}

.telegram-ui.trainer-personal-shell.theme-dark .draft-arrange-panel,
.telegram-ui.theme-dark .draft-arrange-panel,
.telegram-ui.trainer-personal-shell.theme-dark .draft-sort-day,
.telegram-ui.theme-dark .draft-sort-day,
.telegram-ui.trainer-personal-shell.theme-dark .draft-sort-item,
.telegram-ui.theme-dark .draft-sort-item,
.telegram-ui.trainer-personal-shell.theme-dark .structure-starter,
.telegram-ui.theme-dark .structure-starter{
  background:rgba(38,52,64,.74)!important;border-color:rgba(155,180,200,.16)!important;color:#f3f6f8!important
}
.telegram-ui.trainer-personal-shell.theme-dark .draft-sort-day-head,
.telegram-ui.theme-dark .draft-sort-day-head{background:rgba(22,34,44,.36)!important;border-color:rgba(155,180,200,.14)!important}
.telegram-ui.trainer-personal-shell.theme-dark .draft-sort-item,
.telegram-ui.theme-dark .draft-sort-item{background:rgba(32,43,54,.90)!important}
.telegram-ui.trainer-personal-shell.theme-dark .draft-sort-copy strong,
.telegram-ui.theme-dark .draft-sort-copy strong{color:#f3f6f8!important}
.telegram-ui.trainer-personal-shell.theme-dark .draft-sort-copy span,
.telegram-ui.theme-dark .draft-sort-copy span,
.telegram-ui.trainer-personal-shell.theme-dark .draft-sort-day-head small,
.telegram-ui.theme-dark .draft-sort-day-head small{color:#b6c4cf!important}
.telegram-ui.trainer-personal-shell.theme-dark .structure-below-actions,
.telegram-ui.theme-dark .structure-below-actions{border-color:rgba(155,180,200,.14)!important}

@media(max-width:900px){
  .structure-details.form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:620px){
  .draft-sort-board{grid-template-columns:1fr}
  .draft-arrange-head{flex-direction:column}
  .structure-starter{align-items:flex-start;flex-direction:column}
  .structure-starter>div,.structure-starter button{width:100%}
  .structure-row-head{align-items:stretch!important;flex-direction:column!important}
  .structure-row-actions{width:100%}
  .structure-row-actions button{flex:1}
  .structure-details.form-grid{grid-template-columns:1fr}
  .structure-below-actions{justify-content:stretch}
  .structure-below-actions>span{width:100%;margin:0}
  .structure-below-actions button{flex:1}
}
.draft-drag-handle{touch-action:none;cursor:grab}

/* =========================================================
   Stage 3.17.8 — Personal library editing + locked workout edit
   ========================================================= */
.library-item-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap;position:relative}
.library-item-actions form{margin:0}
.library-inline-edit{position:relative}
.library-inline-edit>summary{list-style:none;cursor:pointer;padding:8px 10px;border-radius:9px;border:1px solid var(--fc-border-soft,#dbe3ea);font-size:10px;font-weight:800;color:var(--tg-blue,#3390ec);background:var(--fc-surface-soft,#f8fafc)}
.library-inline-edit>summary::-webkit-details-marker{display:none}
.library-inline-edit[open]>summary{background:var(--tg-blue-soft,rgba(51,144,236,.10))}
.library-edit-form{position:absolute;right:0;top:calc(100% + 7px);z-index:35;width:min(360px,86vw);display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:12px;border:1px solid var(--fc-border-soft,#dbe3ea);border-radius:12px;background:#fff;box-shadow:0 14px 34px rgba(15,23,42,.18)}
.library-edit-form label{font-size:9px;color:var(--fc-muted,#6b7280)}
.library-edit-form input,.library-edit-form select{width:100%;min-height:38px}
.library-edit-form button{grid-column:1/-1}
.workout-access-row-actions{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap}
.locked-workout-order{margin-bottom:12px}
.locked-sort-list{max-width:760px}
.locked-block-editor{display:grid;gap:10px;margin-bottom:10px;padding:12px}
.locked-block-editor .title-row{margin:0}
.locked-block-editor .title-row small{display:block;margin-top:3px;color:var(--fc-muted,#6b7280)}
.locked-resize-form{display:flex;gap:8px;align-items:end;flex-wrap:wrap;padding:9px;border-radius:10px;background:var(--fc-surface-soft,#f8fafc)}
.locked-resize-form label{min-width:190px;font-size:9px;color:var(--fc-muted,#6b7280)}
.locked-exercise-list{display:grid;gap:8px}
.locked-exercise-edit-row{display:grid;grid-template-columns:minmax(150px,.8fr) minmax(250px,1.2fr) minmax(240px,1fr);gap:9px;align-items:start;padding:10px;border:1px solid var(--fc-border-soft,#e5e7eb);border-radius:10px;background:#fff}
.locked-exercise-edit-row>div:first-child strong{display:block;font-size:11px}
.locked-exercise-edit-row>div:first-child small{display:block;margin-top:2px;font-size:9px;color:var(--fc-muted,#6b7280)}
.locked-inline-form{display:flex;gap:6px;align-items:end}
.locked-inline-form select{min-width:150px}
.telegram-ui.theme-dark .library-edit-form,.telegram-ui.trainer-personal-shell.theme-dark .library-edit-form,.telegram-ui.theme-dark .locked-exercise-edit-row,.telegram-ui.trainer-personal-shell.theme-dark .locked-exercise-edit-row{background:rgba(32,43,54,.98)!important;border-color:rgba(155,180,200,.18)!important;color:#f3f6f8!important}
.telegram-ui.theme-dark .locked-resize-form,.telegram-ui.trainer-personal-shell.theme-dark .locked-resize-form{background:rgba(38,52,64,.72)!important}
@media(max-width:820px){
  .locked-exercise-edit-row{grid-template-columns:1fr}
  .locked-inline-form{display:grid;grid-template-columns:1fr auto}
  .workout-access-row-actions{justify-content:stretch}
  .workout-access-row-actions>*{flex:1 1 130px}
  .workout-access-row-actions form button,.workout-access-row-actions .button{width:100%}
}
@media(max-width:620px){
  .library-item-actions{grid-column:1/-1;justify-content:stretch}
  .library-item-actions>*{flex:1 1 100px}
  .library-item-actions form button,.library-item-actions>form,.library-inline-edit>summary{width:100%}
  .library-edit-form{position:fixed;left:12px;right:12px;top:18vh;width:auto;max-height:70vh;overflow:auto;grid-template-columns:1fr}
  .locked-inline-form{grid-template-columns:1fr}
  .locked-resize-form{display:grid;grid-template-columns:1fr}
}

/* =========================================================
   Stage 3.18.0 — Telegram-style avatar editor + history
   ========================================================= */
.avatar-recrop-button{margin-top:8px}
.avatar-history-section{margin-top:16px;padding-top:14px;border-top:1px solid var(--fc-border-soft,#e5e7eb)}
.avatar-history-title{display:flex;flex-direction:column;gap:3px;margin-bottom:10px}
.avatar-history-title strong{font-size:12px}
.avatar-history-title small{font-size:9px;color:var(--fc-muted,#6b7280)}
.avatar-history-empty{font-size:10px;padding:8px 0}
.avatar-history-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(112px,1fr));gap:10px}
.avatar-history-item{display:grid;gap:7px;padding:8px;border:1px solid var(--fc-border-soft,#e5e7eb);border-radius:12px;background:var(--fc-surface-soft,#f8fafc)}
.avatar-history-preview{appearance:none;border:0;padding:0;background:transparent;cursor:pointer;width:76px;height:76px;border-radius:50%;overflow:hidden;justify-self:center}
.avatar-history-preview img{width:100%;height:100%;object-fit:cover;display:block}
.avatar-history-item>small{text-align:center;color:var(--fc-muted,#6b7280);font-size:8px}
.avatar-history-actions{display:grid;grid-template-columns:1fr 1fr;gap:5px}
.avatar-history-actions form{margin:0}.avatar-history-actions button{width:100%;min-height:31px;padding:5px 6px;font-size:8.5px}
.danger-soft{color:#c0392b!important}

.avatar-crop-modal{position:fixed;inset:0;z-index:1200;background:rgba(5,12,18,.76);display:grid;place-items:center;padding:16px;backdrop-filter:blur(8px)}
.avatar-crop-modal[hidden]{display:none!important}.avatar-crop-open{overflow:hidden}
.avatar-crop-panel{width:min(430px,96vw);max-height:94vh;overflow:auto;padding:16px;border-radius:18px;background:#fff;box-shadow:0 24px 70px rgba(0,0,0,.34)}
.avatar-crop-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:14px}.avatar-crop-head strong{display:block;font-size:16px}.avatar-crop-head small{display:block;margin-top:3px;color:#6b7280;font-size:10px}
.avatar-crop-x{width:36px;height:36px;min-height:36px;padding:0;border-radius:50%;font-size:22px;background:rgba(127,145,160,.12);color:inherit}
.avatar-crop-stage{position:relative;width:min(320px,78vw);aspect-ratio:1;margin:0 auto;overflow:hidden;border-radius:50%;background:#111;touch-action:none;cursor:grab;box-shadow:0 0 0 4px rgba(51,144,236,.25)}
.avatar-crop-stage:active{cursor:grabbing}.avatar-crop-stage img{position:absolute;max-width:none!important;user-select:none;pointer-events:none}
.avatar-crop-stage::after{content:"";position:absolute;inset:0;border-radius:50%;box-shadow:inset 0 0 0 2px rgba(255,255,255,.9);pointer-events:none}
.avatar-crop-zoom{display:grid;grid-template-columns:auto 1fr;gap:10px;align-items:center;margin:16px 0 12px;font-size:10px;font-weight:800}.avatar-crop-zoom input{width:100%}
.avatar-crop-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}.avatar-crop-actions button{width:100%}
.telegram-ui.theme-dark .avatar-crop-panel,.telegram-ui.trainer-personal-shell.theme-dark .avatar-crop-panel{background:#202b36;color:#f3f6f8;border:1px solid rgba(155,180,200,.16)}
.telegram-ui.theme-dark .avatar-crop-head small,.telegram-ui.trainer-personal-shell.theme-dark .avatar-crop-head small{color:#b6c4cf}
.telegram-ui.theme-dark .avatar-history-item,.telegram-ui.trainer-personal-shell.theme-dark .avatar-history-item{background:rgba(38,52,64,.72)!important;border-color:rgba(155,180,200,.16)!important}
@media(max-width:520px){.avatar-crop-modal{padding:8px}.avatar-crop-panel{border-radius:16px;padding:13px}.avatar-crop-actions{grid-template-columns:1fr}.avatar-history-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
