/* =============================================
   训练 PWA — 全局样式
   ============================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: var(--font-size-md);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

a { color: var(--color-primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* =============================================
   App Shell
   ============================================= */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* =============================================
   页面容器
   ============================================= */
.page {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  padding-bottom: calc(var(--nav-height) + var(--space-md));
  scroll-behavior: smooth;
}
.page.active {
  display: block;
}
.page::-webkit-scrollbar {
  width: 4px;
}
.page::-webkit-scrollbar-thumb {
  background: var(--color-surface-2);
  border-radius: 4px;
}

/* =============================================
   底部导航
   ============================================= */
.bottom-nav {
  display: flex;
  background: var(--color-surface);
  border-top: 1px solid rgba(255,255,255,0.06);
  height: var(--nav-height);
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  color: var(--color-text-muted);
  transition: color 0.2s;
  font-size: var(--font-size-xs);
}
.nav-item .nav-icon {
  font-size: 20px;
  line-height: 1;
}
.nav-item.active {
  color: var(--color-primary);
}
.nav-item:active {
  opacity: 0.7;
}

/* =============================================
   通用组件
   ============================================= */

/* Card */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.card-header {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-weight: 600;
  transition: all 0.2s;
  width: 100%;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover {
  background: var(--color-primary-dim);
}
.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.btn-secondary:hover {
  background: #303055;
}
.btn-success {
  background: var(--color-success);
  color: white;
}
.btn-outline {
  border: 1px solid var(--color-surface-2);
  color: var(--color-text-secondary);
  background: transparent;
}
.btn-sm {
  padding: 8px 16px;
  font-size: var(--font-size-sm);
}

/* Badge / Tag */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}
.badge-red { background: rgba(230,57,70,0.2); color: var(--color-primary); }
.badge-green { background: rgba(46,204,113,0.2); color: var(--color-success); }
.badge-yellow { background: rgba(243,156,18,0.2); color: var(--color-warning); }
.badge-blue { background: rgba(52,152,219,0.2); color: var(--color-info); }
.badge-gray { background: rgba(156,163,175,0.15); color: var(--color-text-muted); }

/* =============================================
   今日概览页
   ============================================= */
.today-header {
  text-align: center;
  padding: var(--space-lg) 0;
}
.today-date {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}
.today-session-type {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  margin-bottom: var(--space-xs);
}
.today-meta {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
}
.today-notes {
  background: rgba(230,57,70,0.08);
  border-left: 3px solid var(--color-primary);
  padding: var(--space-sm) var(--space-md);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* 今日计划预览 */
.plan-preview {
  display: flex;
  flex-direction: column;
}
.plan-exercise {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.plan-exercise:last-child {
  border-bottom: none;
}
.plan-exercise.superset {
  border-left: 2px solid var(--color-info);
  padding-left: var(--space-sm);
  margin-left: calc(var(--space-sm) * -1);
}
.plan-exercise .plan-ex-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
}
.plan-exercise .plan-ex-target {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* 周进度条 */
.week-progress {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: var(--space-md);
}
.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.week-day .day-name {
  font-size: 10px;
}
.week-day .day-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 2px solid transparent;
}
.week-day .day-dot.completed {
  background: var(--color-success);
  color: white;
}
.week-day .day-dot.today {
  border-color: var(--color-primary);
  background: rgba(230,57,70,0.2);
  color: var(--color-primary);
  font-weight: 700;
}
.week-day .day-dot.future {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}
.week-day .day-dot.rest {
  background: transparent;
  color: var(--color-text-muted);
  font-size: 16px;
  line-height: 28px;
}

/* 容量速览 */
.volume-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.volume-item {
  text-align: center;
  padding: var(--space-sm);
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
}
.volume-item .label {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
}
.volume-item .value {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-primary);
}

/* =============================================
   训练模式页
   ============================================= */
.train-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: var(--space-md);
  position: relative;
}
.train-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.train-back {
  font-size: 24px;
  padding: 4px;
  color: var(--color-text-secondary);
}
.train-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  flex: 1;
}
.train-timer {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
}
.rest-quick-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s;
}
.rest-quick-btn:active {
  transform: scale(0.9);
}
.rest-config-popup {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--color-surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  margin-top: 4px;
  animation: fadeIn 0.15s ease;
}
.rest-config-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* 训练阶段 */
.train-section {
  margin-bottom: var(--space-lg);
}
.train-section-title {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-sm);
  padding-left: var(--space-xs);
}

/* 动作卡片 */
.exercise-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  box-shadow: var(--shadow-sm);
}
.exercise-card.completed {
  border-left: 3px solid var(--color-success);
}
.exercise-card.active {
  border-left: 3px solid var(--color-primary);
}
.exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}
.exercise-name {
  font-weight: 600;
  font-size: var(--font-size-md);
}
.exercise-target {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-top: 2px;
}
.exercise-status {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}
.exercise-status.done {
  color: var(--color-success);
}

/* 每组记录行 */
.set-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 0;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.set-row:first-child {
  border-top: none;
}
.set-num {
  width: 28px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.set-input {
  flex: 1;
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}
.set-input input {
  width: 60px;
  padding: 4px 8px;
  background: var(--color-surface-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-align: center;
  font-size: var(--font-size-sm);
  font-family: var(--font-mono);
}
.set-input input:focus {
  outline: none;
  border-color: var(--color-primary);
}
.set-input label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}
.set-done {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  flex-shrink: 0;
  transition: all 0.2s;
}
.set-done.checked {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

/* 超级组标签 */
.superset-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  background: rgba(52,152,219,0.2);
  color: var(--color-info);
  margin-left: var(--space-sm);
}

/* 训练反馈表单 */
.train-feedback {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(255,255,255,0.06);
}
.feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
.feedback-item label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}
.feedback-item input,
.feedback-item select {
  width: 100%;
  padding: 8px 12px;
  background: var(--color-surface-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--font-size-sm);
}
.feedback-item input:focus,
.feedback-item select:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* RPE 选择器 */
.rpe-selector {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.rpe-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--color-surface-2);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  transition: all 0.15s;
}
.rpe-btn.selected {
  border-color: var(--color-primary);
  background: rgba(230,57,70,0.2);
  color: var(--color-primary);
}
.rpe-btn:hover {
  border-color: var(--color-primary);
}

/* 感受选择 */
.feeling-chips {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.feeling-chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-surface-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  transition: all 0.15s;
}
.feeling-chip.selected {
  border-color: var(--color-primary);
  background: rgba(230,57,70,0.15);
  color: var(--color-primary);
}

/* =============================================
   历史页
   ============================================= */
.history-title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  margin-bottom: var(--space-lg);
}

/* 日历 */
.calendar {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}
.calendar-nav {
  font-size: var(--font-size-lg);
  padding: 4px 8px;
  color: var(--color-text-secondary);
}
.calendar-month {
  font-weight: 700;
  font-size: var(--font-size-md);
}
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.calendar-day {
  padding: 6px 0;
  font-size: var(--font-size-sm);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}
.calendar-day.has-log {
  color: var(--color-text);
  font-weight: 600;
}
.calendar-day.has-log::after {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  background: var(--color-primary);
  border-radius: 50%;
  margin: 2px auto 0;
}
.calendar-day.today {
  background: rgba(230,57,70,0.2);
  color: var(--color-primary);
  font-weight: 700;
}
.calendar-day.other-month {
  opacity: 0.3;
}

/* 训练日志列表 */
.log-list {
  margin-top: var(--space-md);
}
.log-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.log-item:active {
  background: var(--color-surface-2);
}
.log-item-date {
  text-align: center;
  min-width: 44px;
}
.log-item-date .day {
  font-size: var(--font-size-lg);
  font-weight: 700;
}
.log-item-date .month {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
}
.log-item-info {
  flex: 1;
}
.log-item-type {
  font-weight: 600;
  margin-bottom: 2px;
}
.log-item-stats {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  display: flex;
  gap: var(--space-md);
}

/* 训练详情弹窗 */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
}
.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-lg) var(--space-md);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--color-text-muted);
  border-radius: 4px;
  margin: 0 auto var(--space-md);
}

/* =============================================
   设置页
   ============================================= */
.settings-section {
  margin-bottom: var(--space-xl);
}
.settings-section-title {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-sm);
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.settings-row:last-child {
  border-bottom: none;
}
.settings-label {
  font-size: var(--font-size-sm);
}
.settings-desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.settings-value {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Toast 通知 */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 24px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0;
  transition: all 0.3s;
  max-width: 400px;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success {
  border-left: 3px solid var(--color-success);
}
.toast.error {
  border-left: 3px solid var(--color-danger);
}

/* =============================================
   空状态
   ============================================= */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--color-text-muted);
}
.empty-state .icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
}
.empty-state .text {
  font-size: var(--font-size-md);
  margin-bottom: var(--space-sm);
}
.empty-state .sub {
  font-size: var(--font-size-sm);
}

/* =============================================
   加载状态
   ============================================= */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-surface-2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =============================================
   响应式
   ============================================= */
@media (min-width: 480px) {
  .app-shell {
    border-left: 1px solid rgba(255,255,255,0.06);
    border-right: 1px solid rgba(255,255,255,0.06);
  }
}

/* =============================================
   组间休息倒计时
   ============================================= */
.rest-timer-bar {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  width: 100%;
  max-width: 480px;
  background: var(--color-surface);
  border-top: 2px solid var(--color-primary);
  padding: var(--space-md);
  z-index: 250;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
}
.rest-timer-bar.active {
  transform: translateX(-50%) translateY(0);
}
.rest-timer-inner {
  text-align: center;
}
.rest-timer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xs);
}
.rest-timer-ex-name {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rest-timer-label {
  font-size: 10px;
  color: var(--color-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.rest-timer-countdown {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.1;
  margin: var(--space-sm) 0;
  text-shadow: 0 0 20px rgba(230,57,70,0.3);
}
.rest-timer-track {
  width: 100%;
  height: 4px;
  background: var(--color-surface-2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: var(--space-md);
}
.rest-timer-progress {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  transition: width 1s linear;
}
.rest-timer-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}
.rest-timer-btn {
  padding: 8px 20px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-surface-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  background: var(--color-surface-2);
  transition: all 0.15s;
}
.rest-timer-btn:active {
  transform: scale(0.95);
}
.rest-timer-skip {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  font-weight: 600;
}

/* =============================================
   训练内容 - 组状态增强
   ============================================= */
.set-row .set-done.checked + .set-input input {
  opacity: 0.5;
  pointer-events: none;
}
.set-row.completed-row {
  opacity: 0.6;
}
.set-row.completed-row .set-num {
  color: var(--color-success);
}

/* 训练进度指示 */
.exercise-card .progress-dots {
  display: flex;
  gap: 4px;
  margin-top: var(--space-sm);
  justify-content: center;
}
.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-surface-2);
  transition: all 0.2s;
}
.progress-dot.done {
  background: var(--color-success);
}
.progress-dot.active {
  background: var(--color-primary);
  box-shadow: 0 0 6px rgba(230,57,70,0.5);
}

/* =============================================
   训练完成弹窗增强
   ============================================= */
.train-complete-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}
.train-complete-overlay.open {
  display: flex;
}
.train-complete-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  max-width: 340px;
  width: 90%;
  text-align: center;
}
.train-complete-card .big-icon {
  font-size: 56px;
  margin-bottom: var(--space-md);
}
.train-complete-card .title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  margin-bottom: var(--space-xs);
}
.train-complete-card .stats {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.8;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
