/* 跟练 —— 自定义层（Tailwind 负责布局/间距，这里放 Tailwind 不擅长的：
   语义配色变量、巨大数字、安全区、翻色模式、极简动效）

   2026-10-27：
   - 数字再放大一档；mm:ss 单独一档，避免五位数撑出屏
   - 补 iOS 的 -webkit- 前缀 / 100vh 回退 / 输入框 16px 防自动放大
   - 训练区改成可滚动 + 垂直居中，小屏（SE 667）不裁切休息记录卡
*/

:root {
  color-scheme: dark;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

:root {
  /* 弹层在 .screen 之外，必须有全局默认，否则按钮透明 */
  --bg: #000;
  --fg: #fff;
  --mute: #8a8a8a;
  --dim: #4a4a4a;
  --line: #242424;
  --card: #0e0e0e;
}

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  /* iOS 上不让整页跟着手指弹，滚动交给每个 .screen 内部 */
  overflow: hidden;
}

/* ---------- 语义配色：一个 .screen 内所有颜色走变量，休息段整体翻色 ---------- */
.screen {
  --bg: #000;
  --fg: #fff;
  --mute: #8a8a8a;
  --dim: #4a4a4a;
  --line: #232323;
  --card: #0e0e0e;
  background: var(--bg);
  color: var(--fg);
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  transition: background-color .35s ease, color .35s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.screen[data-mode="rest"] {
  --bg: #f4f4f4;
  --fg: #000;
  --mute: #6b6b6b;
  --dim: #b4b4b4;
  --line: #e2e2e2;
  --card: #f5f5f5;
}

/* 主区域独立滚动，底部按钮永远钉在视口底部 */
.screen > main { min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
/* 底部操作区自带底色，滚动内容不会从按钮后面透出来 */
.screen > footer, .screen > div.pb-safe { background: var(--bg); position: relative; z-index: 5; }
/* 顶部渐隐，滚动内容不会硬切在按钮上沿 */
.screen > footer::before {
  content: '';
  position: absolute; left: 0; right: 0; top: -22px; height: 22px;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}

.t-mute { color: var(--mute); }
.t-dim { color: var(--dim); }
.t-fg { color: var(--fg); }
.b-line { border-color: var(--line); }
.bg-card { background: var(--card); }
.bg-fg { background: var(--fg); }
.t-bg { color: var(--bg); }

/* ---------- 数字 ---------- */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* 单个数字 / 秒数：一眼能看清 */
.huge {
  font-size: clamp(6.5rem, 44vw, 16rem);
  line-height: .9;
  letter-spacing: -.05em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
/* 分:秒：字符多，单独一档，别被屏幕裁掉；5 个字符再收一档 */
.huge.time {
  font-size: clamp(5rem, 36vw, 13rem);
  letter-spacing: -.03em;
}
.huge.time.tight {
  font-size: clamp(4rem, 27vw, 10rem);
}
.big {
  font-size: clamp(3rem, 16vw, 5.5rem);
  line-height: 1;
  letter-spacing: -.03em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- 训练屏：内容短时垂直居中，内容长时可滚动 ---------- */
.play-scroll { min-height: 100%; display: flex; flex-direction: column; }
.play-center {
  margin: auto 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: .5rem;
  padding-bottom: .5rem;
}

/* ---------- 组件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 18px;
  min-height: 60px;
  padding: 0 1.5rem;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  transition: transform .12s ease, opacity .12s ease;
  border: 0;
  cursor: pointer;
}
.btn:active { transform: scale(.97); opacity: .85; }
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.btn-block { width: 100%; }

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 1rem;
  border-radius: 9999px;
  border: 1px solid var(--line);
  color: var(--mute);
  font-size: 15px;
  background: transparent;
  transition: all .15s ease;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}
.chip[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
  font-weight: 600;
}

.step-btn {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 24px;
  display: grid;
  place-items: center;
  background: transparent;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}
.step-btn:active { background: var(--line); }
.step-label { white-space: nowrap; }

/* 进度条：每段一格 */
.bar { display: flex; gap: 3px; height: 4px; width: 100%; }
.bar > i { flex: 1; background: var(--line); border-radius: 2px; }
.bar > i.done { background: var(--fg); }
.bar > i.now { background: var(--mute); }

/* 底部安全区 */
.pb-safe { padding-bottom: calc(1.25rem + var(--safe-b)); }
.pt-safe { padding-top: calc(.75rem + var(--safe-t)); }

/* 弹层 */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 60;
  animation: fade .18s ease;
}
.sheet-panel {
  width: 100%; max-width: 560px;
  background: #111; color: #fff;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(24px + var(--safe-b));
  max-height: 82vh;
  max-height: 82dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: up .22s cubic-bezier(.2,.8,.2,1);
  border-top: 1px solid #222;
}
@keyframes fade { from { opacity: 0 } }
@keyframes up { from { transform: translateY(16px); opacity: .6 } }

.toast {
  position: fixed; left: 50%; top: calc(64px + var(--safe-t));
  transform: translateX(-50%);
  background: var(--fg); color: var(--bg);
  padding: 9px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  z-index: 80; max-width: 86vw; text-align: center;
  animation: tap .2s ease;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
@keyframes tap { from { opacity: 0; transform: translate(-50%, -6px) } }

/* 呼吸环 */
.pulse { animation: pulse 3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .25; transform: scale(.92) } 50% { opacity: 1; transform: scale(1) } }

.fade-in { animation: fade .25s ease both; }

@media (prefers-reduced-motion: reduce) {
  .pulse, .fade-in, .sheet-panel, .sheet-mask { animation: none; }
  .screen { transition: none; }
}

/* 小屏（iPhone SE / 8 这一档）：让数字和留白一起收一点，别把按钮挤没 */
@media (max-height: 700px) {
  .huge { font-size: clamp(4.8rem, 36vw, 10rem); }
  .huge.time { font-size: clamp(4rem, 28vw, 8.5rem); }
  .huge.time.tight { font-size: clamp(3.2rem, 22vw, 7rem); }
  .play-center { padding-top: 0; padding-bottom: 0; }
  .btn { min-height: 54px; font-size: 17px; }
}

/* 次级文字按钮（要点 / 不舒服） */
.link-btn {
  color: var(--mute);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 0;
}
.link-btn:active { color: var(--fg); }

/* 输入框：iOS 上字号 <16px 会触发自动放大 */
textarea, input { font-size: 16px; }
textarea { user-select: text; -webkit-user-select: text; }
