/**
 * training-lab.css — Training Lab 페이지 전용 스타일
 *
 * 의존: styles.css의 CSS 변수(--color-*, --space-*, --font-* 등)
 * 클래스 접두사: tl- (Training Lab)
 * 원본: calorie-curve.css에서 훈련 부하/퍼포먼스 섹션 분리
 */

/* ──────────────────────────────────────────────
   1. 레이아웃 & 필터
   ────────────────────────────────────────────── */
.tl-content {
  padding: var(--space-8) var(--space-6);
  max-width: 1200px;
  margin: 0 auto;
}

/* 페이지 헤더 */
.tl-page-header { margin-bottom: var(--space-5); }
.tl-page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
  margin: 0 0 4px;
}
.tl-page-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 0;
}

/* 필터 영역 */
.tl-filter-area {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-6);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.tl-filter-area::-webkit-scrollbar { display: none; }

/* 연도 드롭다운 */
.tl-year-select {
  padding: 4px 28px 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%236B6B76'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  white-space: nowrap;
  flex-shrink: 0;
}
.tl-year-select:focus { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.tl-filter-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* 스포츠 필터 그룹 */
.tl-sport-group {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
/* 모바일: 스포츠 필터 가로 스크롤 */
@media (max-width: 640px) {
  .tl-sport-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;   /* Firefox */
    padding-bottom: 4px;
  }
  .tl-sport-group::-webkit-scrollbar { display: none; } /* Chrome/Safari */
}

.tl-sport-btn {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}
.tl-sport-btn.active {
  background: var(--color-text-primary);
  color: #fff;
  border-color: var(--color-text-primary);
}
.tl-sport-btn:focus { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ── 공통 섹션 카드 (DRY: 개별 섹션 CSS에서 중복 제거) ── */
.tl-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}
.tl-card.hidden { display: none; }

/* ── 공통 인사이트 텍스트 색상 ── */
.tl-insight-good { color: #43A047; font-weight: 600; }
.tl-insight-warn { color: #e84040; font-weight: 600; }

.tl-summary {
  margin-left: auto;
  font-size: 11px;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────
   2. 공통 섹션 타이틀 & 설명
   ────────────────────────────────────────────── */
/* ── 그룹 구분자 (섹션 카테고리 라벨) ── */
.tl-group-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-8) 0 var(--space-4);
  padding: 0;
}
.tl-group-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}
.tl-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.tl-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-3);
}
/* 기준 라벨 — "볼륨 기준" 등 타이틀 옆 보조 텍스트 */
.tl-basis-label {
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-tertiary, #aaa);
  margin-left: 6px;
}

.tl-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0 0 var(--space-4) 0;
}
.tl-desc-sub {
  display: block;
  font-size: 11px;
  color: var(--color-text-secondary);
  opacity: 0.7;
  margin-top: 2px;
}

/* ──────────────────────────────────────────────
   3. MET·hours 히트맵 (GitHub 기여 그래프 스타일)
   ────────────────────────────────────────────── */
/* .tl-heatmap-section — 카드 스타일은 .tl-card 공통 클래스로 적용 */

.tl-hm-wrap {
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: var(--space-2);
}

.tl-hm-container {
  display: inline-grid;
  grid-template-rows: auto repeat(7, 11px);
  grid-auto-columns: 11px;
  grid-auto-flow: column;
  gap: 2px;
  min-width: max-content;
}

.tl-hm-label-day {
  font-size: 9px;
  color: var(--color-text-secondary);
  line-height: 11px;
  text-align: right;
  padding-right: 4px;
  width: 24px;
  grid-column: 1;
}

.tl-hm-label-month {
  font-size: 9px;
  color: var(--color-text-secondary);
  line-height: 11px;
  grid-row: 1;
  white-space: nowrap;
}

.tl-hm-cell {
  width: 11px;
  height: 11px;
  border-radius: 0;
  outline: 1px solid rgba(27, 31, 35, 0.04);
  outline-offset: -1px;
  position: relative;
  cursor: pointer;
}

/* 툴팁 */
.tl-hm-tooltip {
  position: fixed;
  background: var(--color-text-primary);
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 0;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
}
.tl-hm-tooltip.visible { opacity: 1; }

.tl-hm-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: var(--space-3);
  gap: var(--space-3);
}

.tl-hm-legend {
  display: flex;
  align-items: center;
  gap: 3px;
}
.tl-hm-legend-label {
  font-size: 10px;
  color: var(--color-text-secondary);
  margin: 0 2px;
}
.tl-hm-legend-cell {
  width: 11px;
  height: 11px;
  border-radius: 0;
  display: inline-block;
  outline: 1px solid rgba(27, 31, 35, 0.04);
  outline-offset: -1px;
}

.tl-hm-insight {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-top: var(--space-3);
}

.tl-hm-comment {
  font-size: 12px;
  color: var(--color-primary);
  font-weight: 500;
}

/* ──────────────────────────────────────────────
   4. 스포츠별 MET·hours 분포 (도넛 차트)
   ────────────────────────────────────────────── */
/* .tl-metpie-section — 카드 스타일은 .tl-card 공통 클래스로 적용 */

.tl-metpie-body {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  margin-top: var(--space-4);
}

.tl-metpie-chart {
  width: 200px;
  height: 200px;
  flex-shrink: 0;
  position: relative;
}

.tl-metpie-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tl-metpie-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  line-height: 1.4;
}
.tl-metpie-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 0;
  flex-shrink: 0;
}
.tl-metpie-legend-name {
  font-weight: 600;
  color: var(--color-text-primary);
  min-width: 50px;
}
.tl-metpie-legend-val {
  color: var(--color-text-secondary);
}
.tl-metpie-legend-pct {
  font-weight: 600;
  color: var(--color-text-primary);
  margin-left: auto;
}

.tl-metpie-insight {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-top: var(--space-3);
}

/* ──────────────────────────────────────────────
   5. PR 히스토리 타임라인
   ────────────────────────────────────────────── */
/* .tl-pr-section — 카드 스타일은 .tl-card 공통 클래스로 적용 */

.tl-pr-timeline {
  position: relative;
  padding-left: 28px;
  margin-top: var(--space-4);
}
.tl-pr-timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-border);
}

.tl-pr-item {
  position: relative;
  padding: 10px 14px;
  margin-bottom: var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 0;
  cursor: pointer;
  transition: border-color 0.15s;
}
.tl-pr-item:hover { border-color: var(--color-primary); }

.tl-pr-item::before {
  content: '\2605';
  position: absolute;
  left: -24px;
  top: 12px;
  width: 16px;
  height: 16px;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  color: #FFD700;
  background: var(--color-surface);
  border: 2px solid #FFD700;
  border-radius: 0;
  z-index: 1;
}
.tl-pr-item--first::before {
  content: '\25CF';
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.tl-pr-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 4px;
}
.tl-pr-sport {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text-primary);
}
.tl-pr-date {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-left: auto;
}

.tl-pr-body {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.tl-pr-metric {
  font-size: 12px;
  color: var(--color-text-secondary);
}
.tl-pr-value {
  font-weight: 700;
  font-size: 16px;
  color: var(--color-text-primary);
}
.tl-pr-improve {
  font-size: 12px;
  font-weight: 600;
}
.tl-pr-improve--up { color: #43A047; }
.tl-pr-improve--down { color: #43A047; }

.tl-pr-prev {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.tl-pr-more {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: var(--space-2);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 0;
  font-size: 13px;
  color: var(--color-text-secondary);
  cursor: pointer;
  text-align: center;
}
.tl-pr-more:hover {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

/* ──────────────────────────────────────────────
   6. 트레이닝 부하 분석 (CTL/ATL/ACWR)
   ────────────────────────────────────────────── */
/* .tl-load-section — 카드 스타일은 .tl-card 공통 클래스로 적용 */

.tl-load-chart-wrap {
  position: relative;
  height: 260px;
  margin: var(--space-4) 0;
}
.tl-load-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ACWR 게이지 바 */
.tl-load-gauge-wrap { margin: var(--space-4) 0; }
.tl-load-gauge-label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text-primary);
}
.tl-load-gauge-bar {
  position: relative;
  height: 20px;
  display: flex;
  overflow: hidden;
}
.tl-load-gauge-zone {
  height: 100%;
  position: relative;
}
.tl-load-gauge-zone-label {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}
.tl-load-gauge-marker {
  position: absolute;
  top: -8px;
  transform: translateX(-50%);
  z-index: 2;
}
.tl-load-gauge-marker::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--color-text-primary);
}
.tl-load-gauge-val {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.tl-load-insight {
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text-secondary);
  margin-top: var(--space-3);
}
.tl-load-insight strong { color: var(--color-text-primary); }
/* 개별 인사이트 색상 → .tl-insight-good / .tl-insight-warn 공통 클래스로 통합 */
.tl-load-insight .tl-load-warn { color: #e84040; font-weight: 600; }
.tl-load-insight .tl-load-good { color: #43A047; font-weight: 600; }

/* ──────────────────────────────────────────────
   7. 주기화(Periodization) 플래너
   ────────────────────────────────────────────── */
/* .tl-period-section — 카드 스타일은 .tl-card 공통 클래스로 적용 */

.tl-period-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.tl-period-setup-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.tl-period-setup-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* 수평 타임라인 바 */
.tl-period-timeline { margin: var(--space-4) 0; position: relative; }
.tl-period-tl-bar { display: flex; height: 32px; overflow: hidden; }
.tl-period-tl-phase {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 30px;
  position: relative;
}
.tl-period-tl-dates { display: flex; margin-top: 2px; }
.tl-period-tl-date {
  font-size: 9px;
  color: var(--color-text-tertiary);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-period-tl-now {
  position: absolute;
  top: -6px;
  z-index: 2;
  transform: translateX(-50%);
}
.tl-period-tl-now::before {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--color-text-primary);
}
.tl-period-tl-now::after {
  content: '';
  display: block;
  width: 2px;
  height: 44px;
  background: var(--color-text-primary);
  margin: 0 auto;
}
.tl-period-tl-now-label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  color: var(--color-text-primary);
  white-space: nowrap;
}

/* CTL 목표선 차트 */
.tl-period-chart-wrap {
  position: relative;
  height: 220px;
  margin: var(--space-4) 0;
}
.tl-period-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* 현재 단계 상태 카드 */
.tl-period-status { margin: var(--space-3) 0; }
.tl-period-status-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-bg, #f7f7f8);
  border: 1px solid var(--color-border);
}
.tl-period-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  min-width: 56px;
  text-align: center;
}
.tl-period-status-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tl-period-status-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.tl-period-status-sub {
  font-size: 12px;
  color: var(--color-text-secondary);
}
.tl-period-compliance {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 160px;
}
.tl-period-compliance-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--color-border);
  overflow: hidden;
}
.tl-period-compliance-bar {
  height: 100%;
  transition: width 0.5s ease;
}
.tl-period-compliance-val {
  font-size: 14px;
  font-weight: 700;
  min-width: 40px;
  text-align: right;
}

/* 코칭 인사이트 */
.tl-period-insight {
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text-secondary);
  margin-top: var(--space-3);
}
.tl-period-insight strong { color: var(--color-text-primary); }
.tl-period-insight .tl-period-warn { color: #e84040; font-weight: 600; }
.tl-period-insight .tl-period-good { color: #43A047; font-weight: 600; }

/* 플랜 미설정 안내 */
.tl-period-empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--color-text-tertiary);
  font-size: 13px;
}
.tl-period-empty-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-3);
  padding: 8px 20px;
  border: 1px solid var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.tl-period-empty-btn:hover { opacity: 0.85; }

/* ── 설정 모달 ── */
.tl-period-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}
.tl-period-modal-overlay.hidden { display: none; }
.tl-period-modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  width: 520px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.tl-period-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.tl-period-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--color-text-primary);
}
.tl-period-modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: 4px 8px;
}
.tl-period-modal-close:hover { color: var(--color-text-primary); }
.tl-period-modal-body {
  padding: var(--space-4) var(--space-5);
  overflow-y: auto;
  flex: 1;
}
.tl-period-modal-footer {
  display: flex;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* 프리셋 버튼 그룹 */
.tl-period-presets {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.tl-period-preset-btn {
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.tl-period-preset-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.tl-period-preset-desc {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--color-text-tertiary);
  margin-top: 1px;
}

/* 필드 */
.tl-period-field { margin-bottom: var(--space-3); }
.tl-period-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}
.tl-period-input {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text-primary);
  width: 160px;
}
.tl-period-input:focus { outline: none; border-color: var(--color-primary); }

/* 단계 목록 헤더 */
.tl-period-phases-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.tl-period-add-phase {
  padding: 4px 10px;
  border: 1px dashed var(--color-border);
  background: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
}
.tl-period-add-phase:hover { color: var(--color-primary); border-color: var(--color-primary); }

/* 단계 행 */
.tl-period-phase-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.tl-period-phase-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg, #f7f7f8);
  border: 1px solid var(--color-border);
}
.tl-period-phase-color {
  width: 4px;
  height: 32px;
  flex-shrink: 0;
}
.tl-period-phase-select {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  min-width: 80px;
}
.tl-period-phase-weeks {
  width: 55px;
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 12px;
  text-align: center;
}
.tl-period-phase-meth {
  width: 65px;
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 12px;
  text-align: center;
}
.tl-period-phase-unit {
  font-size: 10px;
  color: var(--color-text-tertiary);
  white-space: nowrap;
}
.tl-period-phase-del {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: 2px 6px;
}
.tl-period-phase-del:hover { color: #e84040; }

/* 총 기간 요약 */
.tl-period-total {
  margin-top: var(--space-3);
  font-size: 12px;
  color: var(--color-text-secondary);
  text-align: right;
}
.tl-period-total strong { color: var(--color-text-primary); }

/* 모달 버튼 */
.tl-period-btn-save {
  padding: 8px 24px;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tl-period-btn-save:hover { opacity: 0.85; }
.tl-period-btn-del {
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 12px;
  color: var(--color-text-tertiary);
  cursor: pointer;
}
.tl-period-btn-del:hover { color: #e84040; border-color: #e84040; }

/* ──────────────────────────────────────────────
   8. 운동 부위 균형
   ────────────────────────────────────────────── */

/* ── 수평 바 비교 차트 ── */
.tl-bal-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: var(--space-4);
}
.tl-bal-bar-item {
  position: relative;
}
.tl-bal-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.tl-bal-bar-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.tl-bal-bar-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
}
.tl-bal-bar-pct {
  font-size: 18px;
  font-weight: 700;
}
.tl-bal-bar-track {
  position: relative;
  height: 24px;
  background: var(--color-bg-secondary, #f0f0f5);
  overflow: visible;
}
.tl-bal-bar-fill {
  height: 100%;
  transition: width 0.5s ease;
}
/* 이상 기준선 마커 */
.tl-bal-bar-ideal {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 32px;
  background: var(--color-text-primary);
  opacity: 0.4;
}
.tl-bal-bar-ideal::after {
  content: attr(data-label);
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--color-text-tertiary);
  white-space: nowrap;
}
.tl-bal-bar-grade {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
}
.tl-bal-bar-diff {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-left: 6px;
}

/* ── 상태 요약 카드 ── */
.tl-bal-summary {
  margin-top: var(--space-4);
}
.tl-bal-status-msg {
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
  padding: 10px 14px;
  background: var(--color-bg-secondary, #f8f8fa);
}
.tl-bal-status-msg strong {
  color: var(--color-text-primary);
}
.tl-bal-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.tl-bal-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-bg-secondary, #f8f8fa);
  border-left: 3px solid;
}
.tl-bal-chip-dot {
  width: 8px;
  height: 8px;
}
/* 추천 보완 운동 */
.tl-bal-rec-section {
  margin-top: var(--space-2);
}
.tl-bal-rec-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.tl-bal-rec-title .lucide {
  width: 14px;
  height: 14px;
  transition: transform 0.2s;
}
.tl-bal-rec-title.open .lucide {
  transform: rotate(90deg);
}
.tl-bal-rec-body {
  display: none;
}
.tl-bal-rec-body.open {
  display: block;
}
.tl-bal-rec-group {
  margin-bottom: 8px;
}
.tl-bal-rec-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  margin-bottom: 4px;
}
.tl-bal-rec-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tl-bal-rec-tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--color-border, #e5e5ea);
  color: var(--color-text-primary);
}
.tl-bal-other-note {
  margin-top: var(--space-2);
  font-size: 11px;
  color: var(--color-text-tertiary);
}

/* ── 인사이트 텍스트 (추이 차트 하단) ── */
.tl-balance-insight {
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text-secondary);
}
.tl-balance-insight strong { color: var(--color-text-primary); }
.tl-balance-insight .tl-bal-warn { color: #e84040; font-weight: 600; }
.tl-balance-insight .tl-bal-good { color: #43A047; font-weight: 600; }

/* ── 탭 UI ── */
.tl-bal-trend-tabs {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tl-bal-tab-toggle {
  display: flex;
  gap: 2px;
  background: var(--color-bg-secondary, #f0f0f5);
  padding: 2px;
}
.tl-bal-tab {
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tl-bal-tab.active {
  background: var(--color-surface, #fff);
  color: var(--color-text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.tl-bal-tab-panel {
  display: none;
}
.tl-bal-tab-panel.active {
  display: block;
}

/* ── 목표 게이지 (클래스 기반) ── */
.tl-bal-goal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.tl-bal-goal-label {
  font-size: 13px;
  font-weight: 600;
}
.tl-bal-goal-input {
  width: 100px;
  padding: 4px 8px;
  font-size: 13px;
}
.tl-bal-goal-save {
  padding: 4px 12px;
  font-size: 12px;
}
.tl-bal-gauge {
  margin-top: 8px;
}
.tl-bal-gauge-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}
.tl-bal-gauge-track {
  height: 16px;
  background: #eee;
  overflow: hidden;
  position: relative;
}
.tl-bal-gauge-fill {
  height: 100%;
  transition: width 0.5s;
}
.tl-bal-gauge-pct {
  position: absolute;
  top: 0;
  right: 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  color: #333;
}
.tl-bal-gauge-status {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}
.tl-bal-suggest {
  font-size: 11px;
  color: #888;
  margin-top: 6px;
}
.tl-bal-suggest-btn {
  cursor: pointer;
  background: none;
  border: 1px solid #ccc;
  padding: 2px 8px;
  font-size: 11px;
  margin: 0 2px;
}

/* ── 주간 운동 일지 ── */
.tl-weekly-grid        { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.tl-weekly-card        { padding: 10px; background: var(--color-bg-secondary, #f8f8fa); text-align: center; }
.tl-weekly-card-label  { font-size: 11px; color: var(--color-text-secondary, #888); }
.tl-weekly-card-value  { font-size: 18px; font-weight: 700; margin-top: 2px; }
.tl-weekly-table       { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 12px; }
.tl-weekly-table th,
.tl-weekly-table td    { padding: 6px 8px; border-bottom: 1px solid var(--color-border-light, #f0f0f0); text-align: left; }
.tl-weekly-table th    { font-weight: 600; color: var(--color-text-secondary); font-size: 11px; }
.tl-weekly-coach       { padding: 8px 12px; font-size: 12px; line-height: 1.6; background: var(--color-bg-secondary, #f8f8fa); }
@media (max-width: 640px) {
  .tl-weekly-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── 밸런스 추이 차트 (주간/월간 토글) ── */
.tl-bal-trend-wrap      { margin-top: var(--space-5); }
.tl-bal-trend-header    { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.tl-bal-period-toggle   { display: flex; gap: 4px; }
.tl-bal-period-toggle .tl-sport-btn { padding: 3px 12px; font-size: 11px; }
.tl-bal-trend-chart     { position: relative; height: 220px; margin: var(--space-4) 0; }
.tl-bal-trend-chart canvas { width: 100% !important; height: 100% !important; }

/* ──────────────────────────────────────────────
   9. 인사이트 블록 (공용)
   ────────────────────────────────────────────── */
.tl-insight-block {
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.tl-insight-block div {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.75;
}
.tl-insight-block div + div { margin-top: var(--space-2); }
.tl-insight-block strong { color: var(--color-text-primary); font-weight: 600; }

/* ──────────────────────────────────────────────
   9b. 일일 컨디션 추이 차트
   ────────────────────────────────────────────── */
.tl-condition-chart-wrap {
  position: relative;
  width: 100%;
  margin: var(--space-3) 0;
}
#tlConditionTrendInsight {
  margin-top: var(--space-2);
  font-size: 13px;
  color: var(--color-text-secondary, #666);
  line-height: 1.6;
}
#tlConditionTrendInsight strong {
  font-weight: 600;
}

/* ──────────────────────────────────────────────
   10. 로딩 & 빈 상태
   ────────────────────────────────────────────── */
.tl-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  gap: 16px;
}
.tl-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.tl-loading-text {
  font-size: 13px;
  color: var(--color-text-tertiary);
}

.tl-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 14px;
}
.tl-empty.hidden { display: none; }
/* 공통: tl-section hidden 처리 (HRR 추이, 주간/월간 리포트 등) */
.tl-section.hidden { display: none; }
.tl-empty-sub {
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-top: 6px;
}

/* ──────────────────────────────────────────────
   11. 반응형
   ────────────────────────────────────────────── */
@media (max-width: 767px) {
  .tl-content {
    padding: var(--space-5) var(--space-3);
  }
  .tl-filter-area {
    padding: var(--space-3);
    gap: var(--space-1);
  }
  .tl-hm-wrap { overflow-x: auto; }
  .tl-metpie-body {
    flex-direction: column;
    align-items: stretch;
  }
  .tl-metpie-chart {
    width: 160px;
    height: 160px;
    margin: 0 auto;
  }
  .tl-bal-trend-header { flex-wrap: wrap; }
  .tl-bal-trend-tabs { flex-wrap: wrap; gap: 8px; }
  .tl-bal-chips { flex-direction: column; }
  .tl-bal-goal-row { flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .tl-period-status-card { flex-direction: column; align-items: flex-start; gap: var(--space-2); }
  .tl-period-compliance { width: 100%; }
  .tl-period-modal { width: 100%; max-width: 100vw; }
  .tl-period-phase-row { flex-wrap: wrap; }
}
