/* ========== NUTRITION ========== */

.nutrition-date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
}

.nutrition-date-label {

  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.nutrition-summary {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.nutrition-preview {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.macro-ring-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xs);
  text-align: center;
}

.macro-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.macro-value {

  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--lime);
}

.macro-value.macro-protein { color: #60a5fa; }
.macro-value.macro-carbs { color: #f59e0b; }
.macro-value.macro-fat { color: #f472b6; }

.macro-label {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0.06em;
}

/* Macro Percentage Inputs */
.macro-pct-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.macro-pct-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.macro-pct-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
}

.macro-pct-group input {
  width: 100%;
  text-align: center;
  padding: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 1rem;

}

.macro-pct-group input:focus {
  outline: none;
  border-color: var(--lime-border);
}

.macro-pct-group:nth-child(1) .macro-grams { color: #60a5fa; }
.macro-pct-group:nth-child(2) .macro-grams { color: #f59e0b; }
.macro-pct-group:nth-child(3) .macro-grams { color: #f472b6; }

.macro-grams {

  font-size: 1.125rem;
  letter-spacing: 0.03em;
}

.macro-pct-total {
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem;
  margin-bottom: var(--space-md);
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
}

.macro-pct-total.valid {
  color: var(--lime);
  border-color: var(--lime-border);
}

.macro-pct-total.invalid {
  color: #ef4444;
  border-color: #ef4444;
}

/* Progress Ring Macros */
.macro-ring-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.macro-ring-wrap {
  position: relative;
  width: 100%;
  max-width: 72px;
  aspect-ratio: 1;
}

.macro-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.macro-ring-bg {
  fill: none;
  stroke: var(--border-primary);
  stroke-width: 5;
}

.macro-ring-fill {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.macro-ring-calories { stroke: var(--lime); }
.macro-ring-protein { stroke: #60a5fa; }
.macro-ring-carbs { stroke: #f59e0b; }
.macro-ring-fat { stroke: #f472b6; }

.macro-ring-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--lime);
  white-space: nowrap;
}

.macro-ring-value.macro-protein { color: #60a5fa; }
.macro-ring-value.macro-carbs { color: #f59e0b; }
.macro-ring-value.macro-fat { color: #f472b6; }

.macro-ring-label {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0.06em;
}

.macro-ring-target {
  font-size: 0.625rem;
  color: var(--text-tertiary);
}

.meal-section {
  margin-bottom: var(--space-md);
}

/* Marketplace */
.marketplace-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-primary);
  padding: 8px 0 12px;
  margin-bottom: var(--space-sm);
}

.marketplace-search-bar input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  padding: 0;
}

#coachList {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.coach-card {
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s;
}

.coach-card:active { transform: scale(0.98); }

.coach-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.coach-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.coach-card-info { flex: 1; min-width: 0; }

.coach-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.coach-card-bio {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coach-card-meta {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: 6px;
}

.coach-card-rate {
  font-size: 15px;
  font-weight: 700;
  color: var(--lime);
}

.coach-card-exp,
.coach-card-clients {
  font-size: 12px;
  color: var(--text-tertiary);
}

.coach-card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.coach-card-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  color: var(--text-secondary);
}

/* Macro breakdown modal */
.breakdown-section {
  margin-bottom: var(--space-md);
}

.breakdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 14px;
}

.breakdown-bar-track {
  display: flex;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  overflow: hidden;
  margin-bottom: 8px;
}

.breakdown-bar-fill {
  height: 100%;
  transition: width 0.4s ease;
}

.breakdown-meals {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.breakdown-meal-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 2px 0;
}

.meal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-primary);
  margin-bottom: var(--space-xs);
}

.meal-header h4 {

  font-size: 1.1rem;
  letter-spacing: 0.04em;
  text-transform: none;
}

.meal-cals {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.meal-entries {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.food-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
}

.food-entry-info {
  flex: 1;
  min-width: 0;
}

.food-entry-name {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.food-entry-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.food-entry-cals {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--lime);
  margin-right: var(--space-sm);
  white-space: nowrap;
}

.food-entry-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  font-size: 1rem;
}

.food-entry-delete:hover {
  color: var(--danger);
}

/* Food tabs */
.food-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: var(--space-md);
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 3px;
}

.food-tab {
  flex: 1;
  padding: var(--space-xs) var(--space-sm);
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
}

.food-tab.active {
  background: rgba(255,255,255,0.1);
  color: var(--lime);
  font-weight: 600;
}

/* Meal pill selector */
.food-meal-selector {
  display: flex;
  gap: 6px;
  margin-bottom: var(--space-sm);
}

.food-meal-pill {
  flex: 1;
  padding: 8px 0;
  border-radius: 20px;
  background: var(--bg-tertiary);
  border: 1.5px solid var(--border-primary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;

  text-align: center;
}

.food-meal-pill.active {
  background: var(--lime);
  color: #000;
  border-color: var(--lime);
  font-weight: 600;
}

.food-meal-pill:active { transform: scale(0.95); }

/* Unified search bar */
.food-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-primary);
  border-radius: 0;
  padding: 8px 0 12px;
  margin-bottom: var(--space-sm);
  transition: border-color 0.15s;
}

.food-search-bar:focus-within {
  border-bottom-color: var(--lime);
}

.food-search-bar input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 15px;

  outline: none;
  padding: 0;
  -webkit-appearance: none;
  border-radius: 0;
  box-shadow: none;
}

.food-search-bar input:focus {
  outline: none;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.food-search-barcode {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px;
  display: flex;
}

.food-search-barcode:active { color: var(--lime); }

/* Select dropdown with arrow */
.select-wrapper {
  position: relative;
}

.select-wrapper select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
}

.select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-tertiary);
}

/* Serving stepper */
.serving-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border-primary);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-secondary);
}

.serving-stepper input {
  flex: 1;
  text-align: center;
  border: none;
  border-left: 1px solid var(--border-primary);
  border-right: 1px solid var(--border-primary);
  border-radius: 0;
  background: var(--bg-secondary);
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 0;
}

.stepper-btn {
  width: 48px;
  height: 44px;
  background: none;
  border: none;
  color: var(--lime);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.stepper-btn:active {
  background: rgba(204,255,0,0.1);
}

/* Food search */
.food-search-row {
  display: flex;
  gap: var(--space-xs);
}

.food-search-row input {
  flex: 1;
}

.food-search-results {
  max-height: 50vh;
  overflow-y: auto;
  margin-top: var(--space-sm);
}

.food-result-item {
  padding: var(--space-sm);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  margin-bottom: var(--space-xs);
  cursor: pointer;
  transition: border-color 0.15s;
}

.food-result-item:hover {
  border-color: var(--lime-border);
  background: var(--bg-card-hover);
}

.food-result-name {
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 2px;
}

.food-result-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-sm { font-size: 0.8125rem; }

/* ============================================================
   CHAT — full-bleed view used by client (coachChatView) and
   coach (coachConversationView). The .view itself becomes a
   vertical flex stack: header · messages · composer.
   ============================================================ */

/* Chat views go full-bleed: own header sits at the top, composer at the
   bottom. Height is 100dvh so it tracks the visible viewport when the
   software keyboard opens/closes (Capacitor's native keyboard resize). */
.view.chat-view {
  top: 0;
  bottom: 0;
  height: 100dvh;
  padding-bottom: 0;
  background: var(--bg-primary);
  overflow: hidden;
}

/* Inline `display: block` set by navigateTo is upgraded to flex column
   so header / messages / composer stack correctly. */
.view.chat-view[style*="display: block"],
.view.chat-view[style*="display:block"] {
  display: flex !important;
  flex-direction: column;
}

/* When a chat view is active, push body content above keyboard correctly
   by letting the composer dock above the bottom nav (client) or the safe area
   (coach, where bottom nav is hidden). */
#appContainer.chat-active .top-bar { display: none; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: var(--bg-secondary, #111);
  border-bottom: 0.5px solid var(--border-primary);
  flex-shrink: 0;
}

.chat-header-tap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 4px 0;
  margin: -4px 0;
  border-radius: 8px;
}
.chat-header-tap:active { background: rgba(255,255,255,0.06); }

.chat-header-back {
  background: none;
  border: none;
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin-left: -6px;
  border-radius: 50%;
}
.chat-header-back:active { background: rgba(255,255,255,0.08); }

.chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  background-size: cover;
  background-position: center;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header-avatar.has-photo { color: transparent; }

.chat-header-body {
  flex: 1;
  min-width: 0;
}

.chat-header-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.2;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px 6px;
  -webkit-overflow-scrolling: touch;
}

/* Day separator chip (e.g. "Today", "Yesterday", "Mon, Mar 5") */
.day-sep {
  align-self: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: rgba(255,255,255,0.04);
  padding: 3px 10px;
  border-radius: 10px;
  margin: 10px 0 6px;
  letter-spacing: 0.02em;
}

.chat-bubble {
  max-width: 78%;
  padding: 7px 11px;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.35;
  word-wrap: break-word;
  position: relative;
}

/* Tight stacking — middle of a cluster: smaller corner on adjacent side. */
.chat-bubble.user { align-self: flex-end; background: var(--lime); color: #0a0a0a; }
.chat-bubble.user.cluster-mid,
.chat-bubble.user.cluster-last { border-top-right-radius: 6px; }
.chat-bubble.user.cluster-mid,
.chat-bubble.user.cluster-first { border-bottom-right-radius: 6px; }
.chat-bubble.user.cluster-last,
.chat-bubble.user:not(.cluster-mid):not(.cluster-first) { border-bottom-right-radius: 4px; }

.chat-bubble.assistant,
.chat-bubble.coach {
  align-self: flex-start;
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}
.chat-bubble.coach { background: rgba(96, 165, 250, 0.10); }

.chat-bubble.assistant.cluster-mid,
.chat-bubble.coach.cluster-mid,
.chat-bubble.assistant.cluster-last,
.chat-bubble.coach.cluster-last { border-top-left-radius: 6px; }
.chat-bubble.assistant.cluster-mid,
.chat-bubble.coach.cluster-mid,
.chat-bubble.assistant.cluster-first,
.chat-bubble.coach.cluster-first { border-bottom-left-radius: 6px; }
.chat-bubble.assistant.cluster-last,
.chat-bubble.coach.cluster-last,
.chat-bubble.assistant:not(.cluster-mid):not(.cluster-first),
.chat-bubble.coach:not(.cluster-mid):not(.cluster-first) { border-bottom-left-radius: 4px; }

/* Extra breathing room between distinct clusters (not consecutive). */
.chat-bubble.cluster-start,
.chat-bubble.cluster-solo { margin-top: 8px; }
.chat-messages > .chat-bubble:first-child { margin-top: 0; }

.read-receipt {
  align-self: flex-end;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin: -2px 6px 4px 0;
  letter-spacing: 0.02em;
}

.chat-bubble-time {
  display: block;
  font-size: 10px;
  color: rgba(0,0,0,0.45);
  margin-top: 2px;
  text-align: right;
}
.chat-bubble.assistant .chat-bubble-time,
.chat-bubble.coach .chat-bubble-time { color: var(--text-tertiary); }

.chat-bubble .chat-sender {
  font-size: 0.6875rem;
  font-weight: 500;
  margin-bottom: 2px;
  color: var(--text-tertiary);
}

.chat-typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border-radius: 16px;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

/* ============================================================
   Event card — system messages (workout completed, etc.)
   Centered, neither side, tappable.
   ============================================================ */
.event-card {
  align-self: stretch;
  margin: 6px auto;
  max-width: 88%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(204,255,0,0.08), rgba(204,255,0,0.02));
  border: 0.5px solid rgba(204,255,0,0.18);
  border-radius: 12px;
}
.event-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(204,255,0,0.15);
  color: var(--lime);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.event-card-body { flex: 1; min-width: 0; }
.event-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.event-card-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 1px;
}
/* Sits against the top edge so it lines up with the title, not the middle of
   a two-line card. align-self overrides the flex container's center. */
.event-card-time {
  flex-shrink: 0;
  align-self: flex-start;
  font-size: var(--fs-2xs);
  color: var(--text-tertiary);
  padding-top: 2px;
}

/* ============================================================
   Composer — pill-shaped multiline input + circular send button.
   ============================================================ */
.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  /* Extra 6px buffer above the system home-indicator so the composer never
     looks like it's drowning in the bottom fade. */
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-secondary, #111);
  border-top: 0.5px solid var(--border-primary);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

/* Client chat keeps the bottom tab bar visible — composer needs to clear
   the nav height. Coach drill-in hides the nav so it docks at safe-area. */
#coachChatView .chat-composer {
  padding-bottom: calc(8px + 84px + env(safe-area-inset-bottom, 0px));
}

.chat-input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.35;
  padding: 9px 14px;
  border-radius: 18px;
  max-height: 120px;
  min-height: 36px;
}
.chat-input::placeholder { color: var(--text-tertiary); }
.chat-input:focus { background: rgba(255,255,255,0.09); }

.chat-attach-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  flex-shrink: 0;
  padding: 0;
}
.chat-attach-btn:hover { background: rgba(204,255,0,0.10); color: var(--lime); }
.chat-attach-btn:active { transform: scale(0.92); }

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--lime);
  color: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, opacity 0.15s;
  padding: 0;
}
.chat-send-btn:active { transform: scale(0.92); }
.chat-send-btn:disabled { opacity: 0.4; cursor: default; }

/* Media bubbles */
.chat-bubble:has(.bubble-media) {
  padding: 4px;
  max-width: 70%;
}

.chat-bubble:has(.bubble-media:not(:only-child)) {
  padding: 4px 4px 10px;
}

.bubble-media {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
  cursor: pointer;
  line-height: 0;
  /* The inline aspect-ratio style on this element reserves the right shape
     before the media loads — combined with a fixed width below this keeps
     portrait videos from first rendering as wide loaders. */
  width: 220px;
  max-width: 100%;
  max-height: 360px;
}

.bubble-media img,
.bubble-media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
}

.bubble-media video {
  background: #000;
  cursor: default;
}

.bubble-media.uploading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  border-radius: 12px;
}

.bubble-media-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: bubble-media-spin 0.8s linear infinite;
  z-index: 1;
}

@keyframes bubble-media-spin {
  to { transform: rotate(360deg); }
}

/* "Expired" placeholder shown when an attachment's storage object has been
   auto-deleted by the GCS lifecycle rule and its URL now 404s. */
.bubble-media-expired {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  color: var(--text-tertiary);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px dashed rgba(255,255,255,0.1);
  min-height: 100px;
  min-width: 180px;
}
.bubble-media.expired { background: transparent; }
.bubble-media.expired .bubble-media-expired { display: flex; }
.bubble-media.expired video { display: none; }

/* Fullscreen media viewer with Save-to-Photos action. */
.media-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,0.95);
  flex-direction: column;
}
.media-lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px;
  flex-shrink: 0;
}
.media-lightbox-close {
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.media-lightbox-save {
  background: var(--lime);
  border: none;
  color: #0a0a0a;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 18px;
  cursor: pointer;
}
.media-lightbox-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px));
}
.media-lightbox-body img,
.media-lightbox-body video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  background: #000;
}

.bubble-media-failed {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239,68,68,0.55);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 12px;
}

.bubble-text {
  padding: 6px 10px 4px;
  word-wrap: break-word;
}

.chat-bubble.user .bubble-text { color: #0a0a0a; }

/* Offline indicator */
.offline-indicator {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  right: 0;
  background: var(--danger);
  color: #fff;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 0;
  text-transform: none;
  letter-spacing: 0.08em;
  z-index: 101;
}

.adherence-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  vertical-align: middle;
  margin-left: 4px;
}

.adherence-badge.high {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.adherence-badge.mid {
  background: rgba(234, 179, 8, 0.15);
  color: var(--warning);
}

.adherence-badge.low {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* ========== DAY TOGGLE BUTTONS ========== */
.day-toggle-row {
  display: flex;
  gap: 4px;
}
.day-toggle {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  color: var(--text-secondary);

  font-size: 0.875rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  min-height: 44px;
}
.day-toggle:hover { border-color: var(--lime-border); }
.day-toggle.active {
  background: var(--lime);
  border-color: var(--lime);
  color: #000;
  font-weight: 700;
}
.repeat-summary { margin-bottom: var(--space-xs); }

/* ========== HISTORY CARD IMPROVEMENTS ========== */
.history-exercises {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  line-height: 1.4;
}

/* ========== MARKETPLACE ========== */
.coach-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.coach-avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* ========== DM THREAD LIST (Inbox) ========== */
.dm-thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border-primary);
  cursor: pointer;
  transition: background 0.15s;
}
.dm-thread-item:active { background: var(--bg-tertiary); }
.dm-thread-item.unread .dm-thread-name { color: var(--text-primary); }
.dm-thread-item.unread .dm-thread-preview { color: var(--text-primary); font-weight: 500; }
.dm-thread-item.unread .dm-thread-time { color: var(--lime); font-weight: 600; }

.dm-thread-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-tertiary), rgba(255,255,255,0.05));
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}
.dm-thread-avatar.has-photo { color: transparent; }

.dm-thread-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dm-thread-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dm-thread-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dm-thread-time { font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; }
.dm-thread-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dm-thread-preview {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.dm-thread-preview .preview-icon {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 4px;
  color: var(--lime);
}

.dm-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--lime);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ========== TYPING INDICATOR ========== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  max-width: 60px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ========== CHECK-INS ========== */
.checkin-card {
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border-radius: 16px;
    background: var(--bg-card);
    border: 0.5px solid var(--border-primary);
    cursor: pointer;
    transition: background 0.15s;
}
.checkin-card:active { background: var(--bg-tertiary); }

.checkin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.checkin-status {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.checkin-status.scheduled { background: rgba(234,179,8,0.15); color: #eab308; }
.checkin-status.pending   { background: rgba(59,130,246,0.15); color: #3b82f6; }
.checkin-status.completed { background: rgba(34,197,94,0.15); color: #22c55e; }
.checkin-status.ready     { background: rgba(204,255,0,0.1); color: var(--lime); }

/* Questionnaire scale buttons */
.q-scale-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.q-scale-btn {
    flex: 1;
    min-width: 0;
    padding: 10px 6px;
    font-size: 12px;
    text-align: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.3;
}
.q-scale-btn:active { transform: scale(0.97); }
.q-scale-btn.selected {
    background: rgba(204,255,0,0.1);
    border-color: rgba(204,255,0,0.3);
    color: var(--lime);
    font-weight: 600;
}

/* Coach connection 1-10 rating */
.q-rating-row {
    display: flex;
    gap: 4px;
}
.q-rating-btn {
    width: 32px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.q-rating-btn:active { transform: scale(0.95); }
.q-rating-btn.selected {
    background: var(--lime);
    color: #000;
    border-color: var(--lime);
}

/* Check-in detail read-only answers */
.checkin-section { margin-bottom: var(--space-md); }
.checkin-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin-bottom: var(--space-xs);
    font-weight: 600;
}
.checkin-answer {
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    margin-bottom: 6px;
}
.checkin-answer-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.checkin-answer-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Zoom link button */
.zoom-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(45,140,255,0.12);
    color: #2d8cff;
    border: 1px solid rgba(45,140,255,0.25);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.zoom-link-btn:active { background: rgba(45,140,255,0.2); }
