/* ============================================================
   styles.css — 深色黎明主题，移动优先，大触摸目标
   基础布局、顶栏、主屏训练区、控制按钮。
   设置/记录屏、横幅、弹窗样式见 styles-secondary.css。
   ============================================================ */

:root {
  --bg-deep: #0c0c18;
  --bg: #1a1a2e;
  --bg-elev: #22223c;
  --bg-soft: #2a2a4a;
  --text: #f2efe6;
  --text-dim: #a9a4b8;
  --text-faint: #6d6880;
  --accent: #ff7847;
  --accent-soft: #ffb37e;
  --green: #3ecf8e;
  --green-deep: #2aa06b;
  --yellow: #f5c542;
  --red: #e05252;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-deep);
  background-image:
    radial-gradient(1100px 520px at 85% -12%, rgba(255, 120, 71, 0.16), transparent 62%),
    radial-gradient(900px 600px at -20% 108%, rgba(62, 207, 142, 0.08), transparent 55%),
    linear-gradient(175deg, #131326 0%, var(--bg-deep) 46%, #151528 100%);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* ---------- 屏幕切换 ---------- */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  padding: 16px 18px calc(18px + var(--safe-bottom));
}

.screen.active {
  display: flex;
  animation: screen-in 0.35s ease both;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 14px;
}

.topbar-title h1.app-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.screen-title {
  font-size: 19px;
  font-weight: 700;
  flex: 1;
  text-align: center;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.topbar-spacer {
  width: 44px;
}

.version-badge {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  padding: 4px 0;
  margin: 2px 0 6px;
  user-select: none;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.icon-btn:active {
  transform: scale(0.94);
  background: var(--bg-soft);
}

.back-btn {
  border: none;
  background: transparent;
}

/* ---------- 主屏训练区 ---------- */
.workout-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  overflow: hidden;
}

.phase-card {
  text-align: center;
  width: 100%;
  animation: screen-in 0.4s ease both;
}

.ring-wrap {
  position: relative;
  width: min(80vw, 260px, 34vh);
  margin: 0 auto 16px;
}

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

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 8;
}

.ring-progress {
  fill: none;
  stroke: url(#ring-gradient);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.phase-status {
  font-size: 17px;
  font-weight: 600;
  color: var(--accent-soft);
  max-width: 78%;
  text-align: center;
}

.phase-status.paused-text {
  color: var(--yellow);
}

.elapsed {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--text);
}

.phase-name {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 10px;
}

.phase-sub {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  padding: 0 12px;
}

.tips {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.7;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  text-align: left;
}

/* ---------- 模式切换 ---------- */
.mode-switch {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mode-btns {
  display: flex;
  gap: 6px;
  background: var(--bg-soft);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.mode-btn {
  min-width: 96px;
  min-height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.mode-btn.active {
  background: var(--accent);
  color: #2b0d02;
}

.mode-badge {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 999px;
}

.mode-badge.recommended {
  color: var(--green);
  border: 1px solid rgba(62, 207, 142, 0.35);
  background: rgba(62, 207, 142, 0.08);
}

.mode-badge.manual {
  color: var(--yellow);
  border: 1px solid rgba(245, 197, 66, 0.35);
  background: rgba(245, 197, 66, 0.08);
}

/* 呼吸动画：准备/换侧阶段进度环缓慢脉冲 */
.ring-wrap.breathing .ring {
  animation: breath 4s ease-in-out infinite;
}

@keyframes breath {
  0%, 100% {
    transform: rotate(-90deg) scale(1);
  }
  50% {
    transform: rotate(-90deg) scale(1.045);
  }
}

/* ---------- 控制按钮 ---------- */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  min-height: 60px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s, filter 0.2s;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.btn-start {
  background: linear-gradient(135deg, #3fd69a 0%, var(--green-deep) 100%);
  color: #06281a;
  font-size: 20px;
  min-height: 68px;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  box-shadow: 0 8px 24px rgba(62, 207, 142, 0.22);
}

.controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 10px;
}

.btn-pause {
  background: linear-gradient(135deg, #f8d469 0%, #d9a62e 100%);
  color: #2b2103;
}

.btn-stop {
  background: linear-gradient(135deg, #ee6a6a 0%, #c73e3e 100%);
  color: #2b0808;
}

.btn-skip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
}

/* ---------- 通用 ---------- */
.hidden {
  display: none !important;
}

/* ---------- 平板与宽屏 ---------- */
@media (min-width: 520px) {
  body {
    padding: 24px 0;
  }

  #app {
    height: calc(100% - 48px);
  }

  .screen {
    border-radius: 28px;
    border: 1px solid var(--border);
    background: rgba(19, 19, 38, 0.6);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  }
}

/* ---------- 小屏手机（矮视口）--------- */
/* 仅收缩边距，保持字体/图标尺寸不变，内容放不下则训练区滚动，保证微信WebView与系统浏览器体验一致 */
@media (max-height: 680px) {
  .screen {
    padding: 10px 16px calc(12px + var(--safe-bottom));
  }

  .workout-area {
    overflow-y: auto;
  }

  .ring-wrap {
    width: min(78vw, 260px, 38vh);
    margin-bottom: 8px;
  }

  .topbar {
    padding: 4px 2px 8px;
  }

  .tips {
    margin-top: 6px;
    padding: 8px 14px;
  }

  .controls {
    gap: 8px;
  }
}

/* ---------- 减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 动作清单表格 ---------- */
.plan-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.plan-table th, .plan-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.plan-table th { color: var(--text-dim, #a9a4b8); font-weight: 500; }
