.card {
  background: var(--card); border-radius: var(--radius-card); padding: 16px;
  margin-bottom: var(--card-gap); box-shadow: var(--shadow-card);
}
.card h3 { margin-bottom: 10px; font-size: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control-height); padding: 0 20px; border-radius: var(--radius-button);
  border: none; font-weight: 700; font-size: 15px; transition: var(--transition); width: 100%;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary { background: var(--primary-light); color: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; width: auto; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 14px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; height: var(--control-height); border-radius: var(--radius-input);
  border: 1px solid var(--gray-300); padding: 0 16px; font-size: 16px;
  background: var(--card); color: var(--gray-900);
}
.field textarea { height: auto; min-height: 80px; padding: 12px 16px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); }
.field-hint { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

.segmented {
  display: flex; background: var(--gray-100); border-radius: var(--radius-button);
  padding: 4px; margin-bottom: var(--card-gap); gap: 4px; overflow-x: auto;
}
.segmented button {
  flex: 1; min-width: 64px; height: 40px; border: none; background: transparent;
  border-radius: 16px; font-weight: 600; font-size: 14px; color: var(--gray-700); transition: var(--transition);
}
.segmented button.active { background: var(--primary); color: #fff; }

.toggle {
  position: relative; width: 48px; height: 28px; border-radius: 14px;
  background: var(--gray-300); border: none; transition: var(--transition); flex-shrink: 0;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: var(--transition);
}
.toggle.on { background: var(--primary); }
.toggle.on::after { left: 22px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.toggle-row .toggle-row-label { font-weight: 600; font-size: 14px; color: var(--gray-700); }

.checklist-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--gray-100); }
.checklist-row:last-child { border-bottom: none; }
.check-circle {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--gray-300);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: var(--transition); font-size: 14px; color: #fff; background: transparent;
}
.check-circle.done { background: var(--success); border-color: var(--success); }

.badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; background: var(--primary-light); color: var(--primary-hover); }
.badge-danger { background: #FFE9E9; color: var(--danger); }

/* 접이식 카드 — 홈/준비 탭의 "설명+버튼"류 카드를 기본 접힘으로 둬서 화면 길이를 줄임 */
.toggle-card .toggle-card-header {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: none; text-align: left; padding: 0; margin: 0;
  outline: none; box-shadow: none; -webkit-appearance: none; appearance: none;
  font: inherit; cursor: pointer;
}
.toggle-card .toggle-card-header h3 { margin-bottom: 0; }
.toggle-card .toggle-card-chevron { color: var(--gray-500); font-size: 14px; transition: var(--transition); flex-shrink: 0; margin-left: 8px; }
.toggle-card.open .toggle-card-chevron { transform: rotate(90deg); }
.toggle-card .toggle-card-body { display: none; margin-top: 12px; }
.toggle-card.open .toggle-card-body { display: block; }

.empty-state { text-align: center; padding: 22px 16px; color: var(--gray-500); }
.empty-state .empty-icon { font-size: 30px; margin-bottom: 10px; }

/* 바텀시트 모달 */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .4);
  display: none; align-items: flex-end; justify-content: center; z-index: 200;
}
.sheet-overlay.show { display: flex; }
body.pc-mode .sheet-overlay.show { align-items: center; }
.sheet {
  background: var(--card); width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  border-radius: var(--radius-card) var(--radius-card) 0 0; padding: 24px;
}
body.pc-mode .sheet { border-radius: var(--radius-card); }
.sheet-handle { width: 40px; height: 4px; background: var(--gray-300); border-radius: 2px; margin: 0 auto 16px; }
.sheet-title { font-size: 20px; font-weight: 800; margin-bottom: 16px; color: var(--navy); }

.settings-row {
  display: flex; align-items: center; gap: 14px; padding: 16px 4px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--gray-100); text-align: left;
}
.settings-row:last-child { border-bottom: none; }
.settings-row .settings-icon { font-size: 20px; width: 28px; text-align: center; }
.settings-row .settings-label { flex: 1; font-weight: 600; }
.settings-row .settings-arrow { color: var(--gray-300); }

#toast-container {
  position: fixed; left: 50%; bottom: calc(var(--nav-height) + 24px); transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast { background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 20px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-card); animation: toast-in .2s ease; }
.toast.toast-danger { background: var(--danger); }
.toast.toast-success { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* 세트 리스트 (근력기록) */
/* 순서: [반복수][무게][RPE][완료체크][삭제] — 반복수/무게는 스테퍼 UI가 들어가서 동일하게
   넓게, RPE는 좁게, 체크/삭제는 작은 원형 버튼이라 고정폭 */
.set-row { display: grid; grid-template-columns: 1fr 1fr 0.5fr 26px 28px; gap: 6px; align-items: center; margin-bottom: 8px; }
.set-row .set-index { text-align: center; font-weight: 700; color: var(--gray-500); }
.set-row input { min-width: 0; width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--gray-300); padding: 0 6px; text-align: center; font-size: 13px; }
.set-row .set-remove { width: 28px; height: 28px; border-radius: 50%; border: none; background: var(--gray-100); color: var(--gray-500); flex-shrink: 0; font-size: 12px; }
.set-row .set-check { width: 24px; height: 24px; font-size: 11px; flex-shrink: 0; color: var(--gray-500); }
.set-row .set-check.done { color: #fff; }
.set-row.set-row-done { opacity: .55; }

/* 중량/반복수 입력 옆 +/- 스테퍼 — 그리드 셀 폭을 넓히지 않고 입력창 오른쪽에 얇게 겹쳐 올림 */
.weight-stepper, .reps-stepper { position: relative; min-width: 0; }
.weight-stepper input, .reps-stepper input { width: 100%; padding-right: 20px; }
.weight-stepper .stepper-btns, .reps-stepper .stepper-btns { position: absolute; right: 2px; top: 2px; bottom: 2px; width: 16px; display: flex; flex-direction: column; gap: 1px; }
.weight-stepper .stepper-btns button, .reps-stepper .stepper-btns button {
  flex: 1; border: none; background: var(--gray-100); color: var(--gray-500);
  font-size: 8px; line-height: 1; padding: 0; border-radius: 4px;
}
.weight-stepper .stepper-btns button:active { background: var(--primary-light); color: var(--primary-hover); }
/* 고급모드가 꺼져있어도 그리드 트랙 수(5칸)는 유지해야 나머지 칸이 밀리지 않음 —
   display:none 대신 visibility:hidden으로 자리만 숨김 */
.set-row.field-advanced, .set-row .field-advanced { display: block; visibility: hidden; }
body.advanced-mode .set-row .field-advanced { visibility: visible; }

/* 캘린더 (단순 dot) */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-grid .cal-dow { font-size: 12px; color: var(--gray-500); font-weight: 700; padding-bottom: 8px; }
.cal-day { position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 13px; color: var(--gray-700); }
.cal-day.today { background: var(--primary); color: #fff; font-weight: 800; }
.cal-day.empty { visibility: hidden; }
.cal-day.done::after { content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--success); }
.cal-day.today.done::after { background: #fff; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-nav button { background: none; border: none; font-size: 18px; color: var(--gray-500); padding: 8px; }

/* 타이머 원형 */
.timer-circle {
  width: 220px; height: 220px; border-radius: 50%; border: 8px solid var(--primary-light);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  margin: 24px auto; position: relative;
}
.timer-circle .timer-value { font-size: 40px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.timer-circle .timer-label { font-size: 14px; color: var(--gray-500); margin-top: 4px; }
.timer-circle.pulsing { animation: timer-pulse .2s ease; }
@keyframes timer-pulse { 0% { border-color: var(--primary); } 100% { border-color: var(--primary-light); } }

.preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: var(--card-gap); }
.preset-row button { flex: 1; min-width: 64px; height: 40px; border-radius: 14px; border: 1px solid var(--gray-300); background: var(--card); font-weight: 600; font-size: 14px; }
.preset-row button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 준비 탭: 수면/피로도/컨디션을 셀렉트 3개로 압축해 한 행에 배치 */
.prep-quick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: var(--card-gap); }
.prep-quick-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.prep-quick-label { display: block; font-size: 12px; color: var(--gray-500); margin-bottom: 4px; text-align: center; }
.prep-quick-row select, .prep-quick-row input {
  width: 100%; min-width: 0; height: 44px; border-radius: 12px; border: 1px solid var(--gray-300);
  text-align: center; font-size: 14px; background: var(--card); color: var(--gray-900);
}

/* 스트레칭 체크: 5개 항목을 세로 5행 대신 2열로 압축 */
.stretch-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 12px; }
.stretch-grid .checklist-row { padding: 10px 0; }

.record-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--gray-100); gap: 12px; }
.record-item:last-child { border-bottom: none; }
.record-item .record-item-title { font-weight: 700; }
.record-item .record-item-sub { font-size: 13px; color: var(--gray-500); }
.record-item .record-item-del { background: none; border: none; color: var(--gray-300); font-size: 18px; padding: 4px 8px; flex-shrink: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: var(--card-gap); }
.stat-tile { background: var(--primary-light); border-radius: 18px; padding: 14px; text-align: center; }
.stat-tile.tile-b { background: #FFF3E0; }
.stat-tile.tile-c { background: #E8F0FF; }
.stat-tile .stat-value { font-size: 22px; font-weight: 800; color: var(--navy); }
.stat-tile .stat-label { font-size: 12px; color: var(--gray-700); margin-top: 2px; }
