.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.app-header h1 { margin-bottom: 0; }
.program-heading { margin: 18px 0 14px; }
.program-heading p { margin-top: 6px; }
.program-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.program-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; border: 1px solid #d7dfd9; border-radius: 10px; }
.program-cover { display: flex; position: relative; align-items: center; justify-content: center; width: 100%; aspect-ratio: 1; background: #fff; font-size: clamp(17px, 2.8vw, 30px); font-weight: 750; text-align: center; padding: 12px; color: #205c43; }
.program-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.program-card .card-label { width: 100%; border-top: 1px solid #edf0ed; }
.section-divider { border: 0; border-top: 1px solid #cbd6ce; margin: 32px 0 24px; }
.program-status { margin: 0 0 0 auto; padding: 0 0 0 12px; border-radius: 8px; background: transparent; color: #205c43; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.program-status strong { font-size: 24px; line-height: 1.3; word-break: keep-all; }
.program-status > div { text-align: right; }
.program-status { flex-shrink: 0; max-width: 340px; }
.program-status span { font-size: 22px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.app-storage-warning { margin-bottom: 14px; padding: 10px 14px; background: #fff5df; border-radius: 8px; }
.stats-nav { display: flex; align-items: center; gap: 16px; margin: 20px 0; }
.stats-nav p { color: #5b6a63; }
.stats-controls { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.stats-nav .music-switch { display: inline-flex; align-items: center; gap: 9px; margin-left: auto; padding: 6px 0 6px 8px; min-height: 44px; border: 0; background: transparent; color: #205c43; font-weight: 700; white-space: nowrap; }
.music-switch-track { position: relative; display: block; width: 50px; height: 30px; border-radius: 999px; background: #b3bdb7; transition: background .18s ease; }
.music-switch-knob { position: absolute; top: 3px; left: 3px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff; color: #205c43; font-size: 8px; font-weight: 800; line-height: 1; box-shadow: 0 1px 3px #0003; transition: transform .18s ease; }
.music-switch[aria-checked="true"] .music-switch-track { background: #205c43; }
.music-switch[aria-checked="true"] .music-switch-knob { transform: translateX(20px); }
@media(prefers-reduced-motion:reduce) { .music-switch-track,.music-switch-knob { transition: none; } }
.stats-tabs { display: flex; gap: 8px; }
.stats-tabs [aria-pressed="true"] { background: #205c43; color: #fff; border-color: #205c43; }
.stats-tabs button[aria-pressed="true"]:hover, .period-buttons button[aria-pressed="true"]:hover { background: #174832; color: #fff; }
#stats-result { margin-bottom: 12px; }
#friends-chart { display: block; width: 100%; min-width: 640px; font-size: 12px; fill: #5b6a63; }
.friends-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.friends-legend button { display: flex; align-items: center; gap: 8px; max-width: 100%; font-size: 14px; }
.friends-legend button span:not(.friend-color) { overflow-wrap: anywhere; }
.friends-legend .friend-line-toggle[aria-pressed="false"] { opacity: .5; }
.friend-entry { display: flex; max-width: 100%; border: 1px solid #b5c2ba; border-radius: 6px; overflow: hidden; }
.friends-legend .friend-entry button { border: 0; border-radius: 0; min-width: 0; }
.friends-legend .friend-line-toggle { flex-shrink: 0; border-right: 1px solid #d7dfd9 !important; padding-inline: 8px; }
.friends-legend [data-badge-member][aria-pressed="true"] { background: #e4f0e8; }
.friends-legend [data-badge-member][aria-current="true"] { box-shadow: inset 0 -3px #205c43; font-weight: 700; }
.friends-legend small { color: #5b6a63; white-space: nowrap; }
.friend-color { width: 12px; height: 12px; flex: 0 0 12px; border-radius: 50%; }
.friends-month h4 { margin: 0 0 14px; font-size: 16px; }
.friends-month ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.friend-month-row { width: 100%; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px 14px; padding: 12px; text-align: left; font-size: 14px; }
.friend-month-row > span:first-child { overflow-wrap: anywhere; }
.friend-month-row strong { white-space: nowrap; }
.friend-month-row[aria-current="true"] { border-color: #205c43; background: #e4f0e8; box-shadow: inset 3px 0 #205c43; }
.friend-month-track { grid-column: 1 / -1; height: 14px; display: block; border-radius: 7px; background: #e4eae5; overflow: hidden; }
.friend-month-bar { display: block; height: 100%; border-radius: inherit; }
#friend-badges-panel { overflow-anchor: none; }
@media(max-width:760px) {
  .stats-controls { flex: 0 0 100%; gap: 8px; }
  .stats-controls .stats-tabs { flex: 1; min-width: 0; gap: 5px; }
  .stats-tabs button { flex: 1; padding-inline: 5px; font-size: 13px; white-space: nowrap; }
  .stats-controls .music-switch { flex-shrink: 0; gap: 6px; padding-left: 0; font-size: 13px; }
  .music-switch-track { width: 44px; height: 26px; }
  .music-switch-knob { width: 20px; height: 20px; }
  .music-switch[aria-checked="true"] .music-switch-knob { transform: translateX(18px); }
}
.stats-hero { background: #fff; border: 1px solid #d7dfd9; border-radius: 12px; padding: 24px; margin-bottom: 18px; }
.stats-hero h2 { margin-bottom: 8px; }
#motivation-message { font-size: 18px; font-weight: 600; color: #205c43; }
.stats-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; margin: 18px 0; }
.stat-card { padding: 20px; border: 1px solid #d7dfd9; border-radius: 12px; background: #fff; }
.stat-card span { display: block; color: #5b6a63; font-size: 13px; }
.stat-card strong { display: block; font-size: clamp(20px,2.8vw,28px); margin-top: 8px; }
.stats-panel { background: #fff; border: 1px solid #d7dfd9; border-radius: 12px; padding: 22px; margin-top: 18px; }
.stats-panel h3 { margin: 0; font-size: 20px; }
.chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.period-buttons { display: flex; gap: 6px; }
.period-buttons [aria-pressed="true"] { color: #fff; background: #205c43; border-color: #205c43; }
.chart-scroller { overflow-x: auto; padding: 16px 2px 4px; }
.stats-chart { display: grid; grid-template-columns: repeat(var(--days),minmax(0,1fr)); align-items: end; gap: 2px; min-width: calc(var(--days) * 6px); }
.day-bar { height: 230px; min-width: 0; min-height: 0; border: 0; padding: 0; display: flex; align-items: center; flex-direction: column; justify-content: flex-end; border-radius: 5px; }
.day-bar[aria-pressed="true"] { outline: 2px solid #205c43; outline-offset: -2px; background: #f2f6f3; }
.bar-fill { display: block; width: 100%; max-width: 64px; border-radius: 4px 4px 0 0; }
.bar-amount { visibility: hidden; font-size: 11px; margin-bottom: 5px; font-variant-numeric: tabular-nums; }
.bar-date { height: 16px; font-size: 11px; margin-top: 8px; white-space: nowrap; }
.chart-note { margin: 8px 0 16px; font-size: 12px; color: #5b6a63; }
.day-detail { padding: 14px; border-radius: 8px; background: #f3f5f2; }
.day-detail p { margin-top: 4px; font-size: 14px; }
.badge-celebration { position: fixed; inset: 0; z-index: 20; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 8px; padding: max(20px, calc((100dvh - 600px) / 2)) max(20px, calc((100vw - 760px) / 2)); pointer-events: none; background: radial-gradient(ellipse, #fffaf0ed, #f3f5f240 72%); }
.badge-slot { width: 168px; height: 180px; overflow: hidden; display: grid; place-items: center; }
.badge-face { width: 108px; height: 108px; border: 3px double #ab7736; border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 10px; text-align: center; word-break: keep-all; font-size: 16px; font-weight: 800; color: #77501e; background: #fff9e9; }
.badge-face img { width: 100%; height: 100%; object-fit: contain; }
.stamp-pending { visibility: hidden; }
.stamp-reveal { animation: stamp-in .6s ease-out both, stamp-out .45s ease-in 2.7s forwards; }
@keyframes stamp-in { 0% { transform: scale(2); opacity: 0; } 45% { transform: scale(.9); opacity: 1; } 70% { transform: scale(1.05); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes stamp-out { to { opacity: 0; } }
.badge-gallery { display: grid; grid-template-columns: repeat(auto-fit,minmax(128px,1fr)); gap: 18px; margin-top: 20px; }
.badge-collection-item { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.badge-collection-item:not(.earned) .badge-face, #badge-detail-face.unearned .badge-face { opacity: .5; filter: grayscale(1); }
.badge-collection-item small { color: #5b6a63; font-size: 11px; }
.session-list { list-style: none; padding: 0; margin: 12px 0 0; }
.session-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid #e5ebe7; }
.session-list li div { display: flex; flex-direction: column; gap: 4px; }
.session-list li > strong { white-space: nowrap; font-size: 14px; }
@media (max-width:760px) { .program-grid { gap: 10px; } .program-cover { padding: 6px; } .program-card .card-label { padding: 10px; } .program-card .card-label strong { font-size: 13px; } .program-card .muted { font-size: 11px; } .stats-summary { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; } .stats-hero,.stats-panel { padding: 16px; } .stat-card { padding: 15px; } .app-header h1 { font-size: 24px; } .program-status { flex-wrap: wrap; } .stats-nav { flex-wrap: wrap; } }
@media (prefers-reduced-motion:reduce) { .stamp-reveal { animation: stamp-out .01s linear 2.7s forwards; } }

.badge-celebration .badge-face { width: 136px; height: 136px; font-size: 20px; border-width: 5px; box-shadow: 0 8px 24px #77501e24; }
.stats-hero { position: relative; display: flex; align-items: center; gap: 22px; overflow: hidden; background: #fffaf0; border-color: #ebddba; min-height: 140px; }
.cheer-mascot { position: relative; flex-shrink: 0; display: grid; place-items: center; width: 76px; height: 76px; border-radius: 26px; background: #f7d880; color: #77501e; font-size: 30px; font-weight: 800; transform: rotate(-7deg); }
.cheer-mascot i { position: absolute; right: -9px; top: -14px; color: #d77930; font-size: 25px; font-style: normal; }
.cheer-copy { position: relative; z-index: 1; }
.cheer-caption { display: block; margin-bottom: 8px; color: #946c32; font-size: 12px; letter-spacing: .05em; }
#motivation-message { font-size: clamp(18px, 2.2vw, 24px); font-weight: 750; line-height: 1.6; word-break: keep-all; outline: none; }
.cheer-spark { position: absolute; right: 18px; bottom: -28px; font-size: 130px; color: #edcd7955; }
.cheer-enter .cheer-mascot { animation: cheer-hop 1.1s ease-out both; }
.cheer-enter .cheer-mascot i { animation: cheer-twinkle 1.5s ease-out 2; }
.cheer-enter .cheer-copy { animation: cheer-rise .65s ease-out both; }
@keyframes cheer-hop { 0% { transform: translateY(18px) rotate(-14deg) scale(.8); opacity: 0; } 40% { transform: translateY(-9px) rotate(7deg) scale(1.08); opacity: 1; } 65% { transform: translateY(3px) rotate(-10deg); } 100% { transform: rotate(-7deg); opacity: 1; } }
@keyframes cheer-twinkle { 50% { transform: rotate(30deg) scale(1.3); } }
@keyframes cheer-rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.day-bar:hover .bar-amount, .day-bar:focus-visible .bar-amount { visibility: visible; }
.day-bar:first-child .bar-date { align-self: flex-start; }
.day-bar:last-child .bar-date { align-self: flex-end; }
@media (max-width: 900px) {
  .workout-nav { flex-wrap: wrap; }
  .program-status { margin-left: auto; }
}
@media (max-width: 760px) {
  .program-status { flex-wrap: nowrap; padding-left: 0; gap: 8px; }
  .stats-hero { gap: 14px; }
  .cheer-mascot { width: 54px; height: 60px; font-size: 25px; border-radius: 20px; }
  .badge-slot { width: 100px; height: 128px; }
  .badge-celebration .badge-face { width: 96px; height: 96px; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .cheer-enter .cheer-mascot, .cheer-enter .cheer-mascot i, .cheer-enter .cheer-copy { animation: none; }
}
.day-bar { background: transparent; } .bar-date { position: relative; z-index: 1; }

.program-description { font-weight: 700; word-break: keep-all; text-wrap: balance; }

/* Reuse the existing square cover/contain geometry; only its palette varies. */
.program-card[data-program="cardio_normal"] { --program-tint: #d7ebe5; }
.program-card[data-program="cardio_fast"] { --program-tint: #edf6f2; }
.program-card[data-program="strength_normal"] { --program-tint: #ebe2ce; }
.program-card[data-program="strength_fast"] { --program-tint: #f6f1e6; }
.program-card[data-program="mixed_normal"] { --program-tint: #dfe5d5; }
.program-card[data-program="mixed_fast"] { --program-tint: #f0f3e9; }
.program-cover { background: var(--program-tint, #fff); }
@media (max-width: 360px) { .program-card .card-label strong { font-size: 11px; line-height: 18.2px; white-space: nowrap; } }


/* Program title above the unchanged square image cover. */
.program-title { display: block; width: 100%; padding: 8px 16px 5px; font-size: 32px; line-height: 1.4; text-align: center; background: var(--program-tint, #fff); }
.program-card .card-label { padding-top: 6px; }
@media (max-width: 760px) {
  .program-title { padding: 6px 10px 5px; font-size: 26px; }
  .program-card .card-label { padding-top: 4px; }
}
@media (max-width: 360px) { .program-title { padding-inline: 6px; font-size: 22px; line-height: 36.4px; white-space: normal; } }

.program-summary { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; row-gap: 2px; font-variant-numeric: tabular-nums; }
.program-summary > span { white-space: nowrap; }

.program-title { word-break: keep-all; text-wrap: balance; }

.program-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; row-gap: 6px; }
.program-heading p { grid-column: 1 / -1; margin-top: 0; }
.program-heading #stats-open { justify-self: end; }
@media (max-width: 360px) { .program-heading h2 { font-size: 20px; } }
.program-heading #stats-open { min-height: 56px; padding: 12px 22px; font-size: 18px; font-weight: 700; }
@media (max-width: 360px) { .program-heading #stats-open { padding-inline: 14px; } }

/* Match the header/navigation to the occupied player columns, only in workout view. */
main:has(#workout:not([hidden])) { --player-content-width: min(100%, calc(min(60vh, 624px) + 316px)); --player-content-width: min(100%, calc(min(60dvh, 624px) + 316px)); }
main:has(#workout:not([hidden])) > .app-header,
#workout { width: var(--player-content-width, 100%); margin-inline: auto; }
.workout-nav { flex-wrap: wrap; }
@media (max-width: 1000px) {
  main:has(#workout:not([hidden])) { --player-content-width: min(100%, calc(min(52.8vh, 528px) + 316px)); --player-content-width: min(100%, calc(min(52.8dvh, 528px) + 316px)); }
}
@media (max-width: 760px) {
  main:has(#workout:not([hidden])) { --player-content-width: min(100%, 52.8vh, 384px); --player-content-width: min(100%, 52.8dvh, 384px); }
}
.workout-nav .program-status { max-width: min(340px, 100%); }
.program-status > div { min-width: 0; overflow-wrap: anywhere; }

/* Supplied PNGs already contain their frame and ribbon. */
.badge-face.badge-image { border: 0; border-radius: 0; padding: 0; background: transparent; box-shadow: none; }
.badge-group-title { grid-column: 1 / -1; margin: 12px 0 0; font-size: 17px; color: #205c43; }
button.badge-collection-item { min-width: 0; padding: 10px 4px; border: 1px solid transparent; border-radius: 12px; background: transparent; }
button.badge-collection-item:hover, button.badge-collection-item:focus-visible { background: #f3f6f3; border-color: #b6cabb; }
.badge-collection-item strong { font-size: 13px; word-break: keep-all; }
.badge-celebration { padding: 16px max(16px, calc((100vw - 560px) / 2)); }
#badge-detail { width: min(400px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border: 1px solid #d7dfd9; border-radius: 18px; color: #263d30; text-align: center; }
#badge-detail::backdrop { background: #14251c88; }
#badge-detail form { display: flex; justify-content: flex-end; }
#badge-detail-face .badge-face { width: 180px; height: 180px; margin: 0 auto 12px; }
#badge-detail p { margin-top: 12px; line-height: 1.6; word-break: keep-all; }
#badge-detail-state, #badge-detail-progress { color: #5b6a63; font-size: 13px; }
@media (max-width: 600px) {
  .badge-gallery { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .badge-celebration { padding: 16px max(16px, calc((100vw - 260px) / 2)); }
  .badge-celebration .badge-slot { width: 110px; height: 136px; }
  .badge-celebration .badge-face { width: 108px; height: 108px; }
}
