/* SLPT R31 UI33B
   Approved card-system, Programs and Share refinement.
   UI33A remains the canonical app-wide workspace authority.
   This layer only refines approved surfaces and spacing. */

html[data-context="app-wide"],
html[data-context="clinical"]{
  --r31-ui33b-paper:#f5f2ec;
  --r31-ui33b-paper-2:#eeeae3;
  --r31-ui33b-ink:#131619;
  --r31-ui33b-muted:#60686e;
  --r31-ui33b-line:rgba(18,22,25,.12);
}

/* ====================================================================== */
/* APP-WIDE WHITE CARD EXTENSION                                          */
/* ====================================================================== */

html[data-context="app-wide"] :where(
  .ui2-clinical-gold-overview>article,
  .ui2-clinical-gold-launch-grid>button,
  .ui2-assessment-gold-overview>article,
  .ui2-assessment-gold-tool-grid>button,
  .ui2-performance-gold-overview>article,
  .ui2-performance-gold-tools>button,
  .ui2-performance-gold-schedule>article,
  .ui2-nutrition-quick-grid>button,
  .ui2-academy-gold-progress>article,
  .ui2-academy-quick>button,
  .r26r11-learning-summary>article,
  .ui2-business-summary>div,
  .ui2-business-quick-grid>button,
  .ui2-prg-card-stats>span
),
html[data-context="clinical"] :where(
  .ui2-clinical-gold-overview>article,
  .ui2-clinical-gold-launch-grid>button
){
  background:var(--r31-ui33b-paper)!important;
  color:var(--r31-ui33b-ink)!important;
  border-color:rgba(255,255,255,.82)!important;
  box-shadow:0 10px 24px rgba(0,0,0,.15),inset 0 1px 0 #fff!important;
}

html[data-context="app-wide"] :where(
  .ui2-clinical-gold-overview>article,
  .ui2-clinical-gold-launch-grid>button,
  .ui2-assessment-gold-overview>article,
  .ui2-assessment-gold-tool-grid>button,
  .ui2-performance-gold-overview>article,
  .ui2-performance-gold-tools>button,
  .ui2-performance-gold-schedule>article,
  .ui2-nutrition-quick-grid>button,
  .ui2-academy-gold-progress>article,
  .ui2-academy-quick>button,
  .r26r11-learning-summary>article,
  .ui2-business-summary>div,
  .ui2-business-quick-grid>button,
  .ui2-prg-card-stats>span
) :where(h1,h2,h3,h4,h5,b,strong,p,small,span,em),
html[data-context="clinical"] :where(
  .ui2-clinical-gold-overview>article,
  .ui2-clinical-gold-launch-grid>button
) :where(h1,h2,h3,h4,h5,b,strong,p,small,span,em){
  color:inherit!important;
}

html[data-context="app-wide"] :where(
  .ui2-clinical-gold-overview>article,
  .ui2-assessment-gold-overview>article,
  .ui2-performance-gold-overview>article,
  .ui2-academy-gold-progress>article,
  .r26r11-learning-summary>article,
  .ui2-business-summary>div,
  .ui2-prg-card-stats>span
) small{
  color:var(--r31-ui33b-muted)!important;
  opacity:1!important;
}

/* Keep active/action accent language orange, without orange card frames. */
html[data-context="app-wide"] :where(
  .ui2-clinical-gold-launch-grid>button,
  .ui2-assessment-gold-tool-grid>button,
  .ui2-performance-gold-tools>button,
  .ui2-nutrition-quick-grid>button,
  .ui2-academy-quick>button,
  .ui2-business-quick-grid>button
):hover{
  border-color:rgba(255,118,0,.30)!important;
  box-shadow:0 13px 30px rgba(0,0,0,.18),inset 0 1px 0 #fff!important;
}

/* ====================================================================== */
/* PLANS & USERS CLIENT WORKSPACE                                         */
/* ====================================================================== */

.r31-cws3-profile-grid{
  grid-template-columns:1fr!important;
  gap:8px!important;
}

.r31-cws3-profile-form{
  padding:0!important;
  overflow:hidden;
}

.r31-cws3-profile-form>header{
  min-height:62px;
  padding:11px 13px!important;
  align-items:center!important;
  gap:10px!important;
}

.r31-cws3-profile-form>header>div:first-child{
  min-width:0;
  flex:1 1 auto;
}

.r31-cws3-profile-form>header h4{
  margin:2px 0 0!important;
  font-size:14px!important;
}

.r31-cws3-profile-form>header small{
  font-size:10px!important;
}

.r31-ui33b-profile-toggle{
  appearance:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-width:78px;
  min-height:32px;
  margin-left:auto;
  padding:6px 9px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:8px;
  background:rgba(255,255,255,.045);
  color:#eef3f5;
  font:inherit;
  font-size:11px;
  cursor:pointer;
}

.r31-ui33b-profile-toggle:hover{
  border-color:rgba(255,118,0,.28);
  background:rgba(255,118,0,.07);
}

.r31-cws3-profile-form.is-collapsed>:not(header){
  display:none!important;
}

.r31-cws3-profile-form:not(.is-collapsed)>.r31-cws3-fields{
  padding:0 13px 10px!important;
}

.r31-cws3-profile-form:not(.is-collapsed)>.r31-cws3-hint{
  margin:0 13px 10px!important;
}

.r31-cws3-profile-form:not(.is-collapsed)>button[type="submit"]{
  width:auto!important;
  min-width:132px!important;
  margin:0 13px 13px!important;
  align-self:start!important;
}

.r31-cws3-profile-form textarea{
  min-height:76px!important;
}

.r31-cws3-toggle{
  order:3;
  font-size:10.5px!important;
}

.r31-cws3-toggle input{
  width:16px!important;
  height:16px!important;
}

/* Diary geometry reconciliation. */
.r31-cws3-card form[data-cws3-diary-create],
.r31-cws3-card form[data-cws3-diary-edit]{
  display:grid;
  gap:12px!important;
}

.r31-cws3-card form[data-cws3-diary-create]>.ui2-live-action,
.r31-cws3-card form[data-cws3-diary-edit]>.r31-cws3-actions{
  margin-top:4px!important;
}

.r31-cws3-card form[data-cws3-diary-create]>.ui2-live-action{
  justify-self:start!important;
  min-width:140px!important;
}

.r31-cws3-form-grid{
  gap:10px 12px!important;
}

.r31-cws3-form-grid label{
  gap:6px!important;
}

.r31-cws3-form-grid input,
.r31-cws3-form-grid select,
.r31-cws3-form-grid textarea{
  min-height:39px!important;
  padding:8px 10px!important;
}

.r31-cws3-form-grid textarea{
  min-height:86px!important;
}

/* ====================================================================== */
/* PROGRAM LIBRARY: FOUR CARDS PER ROW                                    */
/* ====================================================================== */

html[data-route="programs"] .ui2-prg-card-grid{
  display:grid!important;
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  gap:10px!important;
  align-items:stretch!important;
}

html[data-route="programs"] .ui2-prg-program-card{
  min-width:0!important;
  padding:10px!important;
  border-radius:12px!important;
  display:flex!important;
  flex-direction:column!important;
  gap:0!important;
}

html[data-route="programs"] .ui2-prg-program-card h3{
  margin:9px 0 5px!important;
  font-size:14px!important;
  line-height:1.25!important;
}

html[data-route="programs"] .ui2-prg-program-card>p{
  min-height:0!important;
  margin:0!important;
  display:-webkit-box!important;
  -webkit-box-orient:vertical!important;
  -webkit-line-clamp:3!important;
  overflow:hidden!important;
  color:#9eaab0!important;
  font-size:11.5px!important;
  line-height:1.45!important;
}

html[data-route="programs"] .ui2-prg-card-stats{
  grid-template-columns:repeat(3,minmax(0,1fr))!important;
  gap:5px!important;
  margin:10px 0!important;
}

html[data-route="programs"] .ui2-prg-card-stats>span{
  min-width:0!important;
  padding:7px 6px!important;
  text-align:center!important;
}

html[data-route="programs"] .ui2-prg-card-stats b{
  color:var(--r31-ui33b-ink)!important;
  font-size:14px!important;
}

html[data-route="programs"] .ui2-prg-card-stats small,
html[data-route="programs"] .ui2-prg-card-stats span{
  color:var(--r31-ui33b-muted)!important;
}

html[data-route="programs"] .ui2-prg-program-card footer{
  margin-top:auto!important;
  padding-top:9px!important;
  gap:6px!important;
  flex-wrap:wrap!important;
}

.r31-ui33b-open-program{
  width:100%!important;
  min-height:34px!important;
  border:1px solid rgba(255,118,0,.55)!important;
  border-radius:8px!important;
  background:rgba(255,118,0,.07)!important;
  color:#ff9a49!important;
  font-weight:750!important;
  font-size:11px!important;
}

.r31-ui33b-open-program:hover{
  background:rgba(255,118,0,.13)!important;
  border-color:rgba(255,118,0,.72)!important;
  color:#fff!important;
}

/* ====================================================================== */
/* PROGRAM DETAIL: COMPACT STRUCTURE + NAVIGATION                         */
/* ====================================================================== */

html[data-route="programs"] .ui2-prg-detail{
  gap:10px!important;
}

html[data-route="programs"] .ui2-prg-detail>.ui2-prg-section-head{
  padding:14px 15px!important;
  gap:12px!important;
}

html[data-route="programs"] .ui2-prg-detail>.ui2-prg-section-head h2{
  margin:3px 0 4px!important;
  font-size:23px!important;
  line-height:1.18!important;
}

html[data-route="programs"] .ui2-prg-detail>.ui2-prg-section-head p{
  max-width:900px!important;
  margin:0!important;
  line-height:1.45!important;
}

html[data-route="programs"] .ui2-prg-detail-meta{
  gap:6px!important;
  margin:0!important;
}

.r31-ui33b-program-detail-layout{
  display:grid;
  grid-template-columns:220px minmax(0,1fr);
  gap:10px;
  align-items:start;
}

.r31-ui33b-program-rail{
  position:sticky;
  top:10px;
  display:grid;
  gap:6px;
  max-height:calc(100vh - 190px);
  overflow:auto;
  padding:10px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:11px;
  background:var(--r31-ui33-dark,#090c0e);
}

.r31-ui33b-program-rail>header{
  padding:2px 2px 7px;
  border-bottom:1px solid rgba(255,255,255,.07);
}

.r31-ui33b-program-rail>header small{
  display:block;
  color:#ff913a;
  font-size:9.5px;
  font-weight:850;
  letter-spacing:.07em;
  text-transform:uppercase;
}

.r31-ui33b-program-rail>header b{
  display:block;
  margin-top:2px;
  color:#f1f4f5;
  font-size:13px;
}

.r31-ui33b-program-rail button{
  width:100%;
  min-height:34px;
  padding:7px 8px;
  border:1px solid rgba(255,255,255,.07);
  border-radius:8px;
  background:rgba(255,255,255,.025);
  color:#b7c1c5;
  text-align:left;
  font:inherit;
  font-size:10.5px;
  cursor:pointer;
}

.r31-ui33b-program-rail button:hover{
  border-color:rgba(255,118,0,.25);
  background:rgba(255,118,0,.06);
  color:#fff;
}

.r31-ui33b-program-rail button[data-level="block"]{
  color:#eef3f5;
  font-weight:750;
}

html[data-route="programs"] .ui2-prg-detail-blocks{
  min-width:0!important;
  display:grid!important;
  gap:10px!important;
}

html[data-route="programs"] .ui2-prg-detail-block{
  padding:11px!important;
  border-radius:11px!important;
}

html[data-route="programs"] .ui2-prg-detail-block>header{
  margin-bottom:7px!important;
}

html[data-route="programs"] .ui2-prg-detail-block h3{
  margin:2px 0!important;
  font-size:16px!important;
}

html[data-route="programs"] .ui2-prg-detail-week{
  padding:9px!important;
  margin-top:7px!important;
  border-radius:9px!important;
}

html[data-route="programs"] .ui2-prg-detail-week>header{
  padding:7px 8px!important;
  margin:-1px -1px 7px!important;
}

html[data-route="programs"] .ui2-prg-detail-session{
  padding:8px!important;
  margin-top:7px!important;
  border-radius:8px!important;
}

html[data-route="programs"] .ui2-prg-detail-session h4{
  margin:0 0 6px!important;
  font-size:13px!important;
}

html[data-route="programs"] .ui2-prg-detail-ex{
  padding:8px!important;
  margin-top:5px!important;
  border-radius:8px!important;
}

html[data-route="programs"] .ui2-prg-detail-ex-head{
  gap:8px!important;
}

html[data-route="programs"] .ui2-prg-detail-prescription{
  gap:5px!important;
  margin-top:6px!important;
}

html[data-route="programs"] .ui2-prg-detail-prescription span{
  padding:6px!important;
  min-height:40px!important;
}

/* ====================================================================== */
/* SHARE PAGE PROFESSIONAL REFINEMENT                                     */
/* ====================================================================== */

html[data-route="share"] .ui2-share-studio{
  display:grid!important;
  grid-template-columns:minmax(0,1.2fr) minmax(360px,.8fr)!important;
  gap:14px!important;
  align-items:start!important;
}

html[data-route="share"] .ui2-share-composer,
html[data-route="share"] .ui2-share-preview{
  padding:16px!important;
  border:1px solid rgba(255,255,255,.11)!important;
  border-radius:13px!important;
  background:var(--r31-ui33-dark,#090c0e)!important;
  box-shadow:0 16px 38px rgba(0,0,0,.24),inset 0 1px 0 rgba(255,255,255,.04)!important;
}

html[data-route="share"] .ui2-share-section-head{
  margin-bottom:12px!important;
}

html[data-route="share"] .ui2-share-section-head h2{
  margin:3px 0 4px!important;
}

html[data-route="share"] .ui2-share-controls{
  display:grid!important;
  grid-template-columns:1.2fr .8fr .8fr!important;
  gap:8px!important;
  margin-bottom:10px!important;
}

html[data-route="share"] .ui2-share-composer .ui2-field{
  display:grid!important;
  gap:5px!important;
  color:#b8c2c6!important;
  font-size:10.5px!important;
  font-weight:650!important;
}

html[data-route="share"] .ui2-share-composer input,
html[data-route="share"] .ui2-share-composer select,
html[data-route="share"] .ui2-share-composer textarea{
  width:100%!important;
  min-height:39px!important;
  padding:8px 10px!important;
  border:1px solid rgba(255,255,255,.12)!important;
  border-radius:8px!important;
  background:#11181b!important;
  color:#eef3f5!important;
  box-sizing:border-box!important;
  outline:0!important;
}

html[data-route="share"] .ui2-share-composer textarea{
  min-height:82px!important;
  resize:vertical!important;
}

html[data-route="share"] .ui2-share-composer input:focus,
html[data-route="share"] .ui2-share-composer select:focus,
html[data-route="share"] .ui2-share-composer textarea:focus{
  border-color:rgba(255,118,0,.42)!important;
  box-shadow:0 0 0 3px rgba(255,118,0,.06)!important;
}

html[data-route="share"] .ui2-share-types{
  display:flex!important;
  flex-wrap:wrap!important;
  gap:6px!important;
  margin:0 0 11px!important;
}

html[data-route="share"] .ui2-share-types button{
  min-height:32px!important;
  padding:6px 10px!important;
  border:1px solid rgba(255,255,255,.10)!important;
  border-radius:999px!important;
  background:rgba(255,255,255,.035)!important;
  color:#bcc6ca!important;
}

html[data-route="share"] .ui2-share-types button.active{
  border-color:rgba(255,118,0,.42)!important;
  background:rgba(255,118,0,.09)!important;
  color:#ff9b4d!important;
}

html[data-route="share"] .ui2-share-privacy,
html[data-route="share"] .ui2-share-metrics{
  margin-top:11px!important;
  padding:12px!important;
  border:1px solid rgba(255,255,255,.08)!important;
  border-radius:10px!important;
  background:rgba(255,255,255,.025)!important;
}

html[data-route="share"] .ui2-share-privacy{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:7px!important;
}

html[data-route="share"] .ui2-share-privacy legend{
  grid-column:1/-1!important;
  padding:0 4px!important;
  color:#eef3f5!important;
  font-size:11px!important;
  font-weight:800!important;
}

html[data-route="share"] .ui2-share-privacy label,
html[data-route="share"] .ui2-share-metrics label{
  min-width:0!important;
  padding:8px 9px!important;
  border:1px solid rgba(255,255,255,.075)!important;
  border-radius:8px!important;
  background:rgba(255,255,255,.025)!important;
}

html[data-route="share"] .ui2-share-actions{
  display:flex!important;
  flex-wrap:wrap!important;
  gap:7px!important;
  margin-top:12px!important;
}

html[data-route="share"] .ui2-share-actions button{
  min-height:36px!important;
  padding:8px 12px!important;
  border-radius:8px!important;
}

html[data-route="share"] .ui2-share-preview{
  position:sticky!important;
  top:10px!important;
}

html[data-route="share"] .ui2-share-history{
  margin-top:12px!important;
  padding-top:11px!important;
  border-top:1px solid rgba(255,255,255,.08)!important;
}

/* ====================================================================== */
/* RESPONSIVE RECONCILIATION                                              */
/* ====================================================================== */

@media(max-width:1280px){
  html[data-route="programs"] .ui2-prg-card-grid{
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
  }
}

@media(max-width:1020px){
  html[data-route="programs"] .ui2-prg-card-grid{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  .r31-ui33b-program-detail-layout{
    grid-template-columns:1fr!important;
  }
  .r31-ui33b-program-rail{
    position:static!important;
    max-height:none!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  .r31-ui33b-program-rail>header{
    grid-column:1/-1!important;
  }
  html[data-route="share"] .ui2-share-studio{
    grid-template-columns:1fr!important;
  }
  html[data-route="share"] .ui2-share-preview{
    position:static!important;
  }
}

@media(max-width:760px){
  html[data-route="programs"] .ui2-prg-card-grid{
    grid-template-columns:1fr!important;
  }
  .r31-ui33b-program-rail{
    grid-template-columns:1fr!important;
  }
  html[data-route="share"] .ui2-share-controls{
    grid-template-columns:1fr!important;
  }
  html[data-route="share"] .ui2-share-privacy{
    grid-template-columns:1fr!important;
  }
  .r31-cws3-profile-form>header{
    flex-wrap:wrap!important;
  }
  .r31-ui33b-profile-toggle{
    order:2;
  }
  .r31-cws3-toggle{
    order:3;
  }
}

@media(prefers-reduced-motion:reduce){
  .r31-ui33b-profile-toggle,
  .r31-ui33b-open-program,
  .r31-ui33b-program-rail button{
    transition:none!important;
  }
}
