/* ============================================================
   styles.css — 运动选择器
   深色黎明主题，移动优先，大触摸目标。
   与 exercise-helper / dinner-workout 共用同一套视觉变量。
   ============================================================ */

:root {
  color-scheme: dark;
  --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);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

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

/* ---------- 屏幕切换 ---------- */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 100dvh;
  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;
}

.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;
}

/* ---------- 滚动区 ---------- */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 4px 0 8px;
  -webkit-overflow-scrolling: touch;
}

/* ---------- 运动卡片 ---------- */
.workout-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.workout-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s, border-color 0.2s, background 0.2s;
  animation: card-in 0.4s ease both;
}

.workout-card:nth-child(2) {
  animation-delay: 0.06s;
}

.workout-card:nth-child(3) {
  animation-delay: 0.12s;
}

.workout-card:active {
  transform: scale(0.98);
  background: var(--bg-soft);
}

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

.wc-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.wc-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.wc-sub {
  font-size: 13px;
  color: var(--accent-soft);
  font-weight: 600;
}

.wc-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}

.wc-chip {
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.wc-chip-off {
  opacity: 0.55;
}

.wc-start {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, #3fd69a 0%, var(--green-deep) 100%);
  color: #06281a;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  box-shadow: 0 6px 18px rgba(62, 207, 142, 0.18);
  transition: transform 0.1s, filter 0.2s;
}

.workout-card:active .wc-start {
  transform: scale(0.94);
}

/* ---------- 自动进入区域 ---------- */
.auto-section {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  animation: card-in 0.4s ease 0.12s both;
}

.auto-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  cursor: pointer;
}

.auto-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.auto-title {
  font-size: 15.5px;
  font-weight: 600;
}

.auto-hint {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
}

.auto-row input[type="checkbox"] {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  accent-color: var(--green);
  cursor: pointer;
}

/* ---------- 设置卡片与字段 ---------- */
.settings-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.card h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-soft);
  margin-bottom: 14px;
  letter-spacing: 0.05em;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  font-size: 15px;
  border-top: 1px solid var(--border);
}

.field-row:first-of-type {
  border-top: none;
}

.field-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--green);
  cursor: pointer;
}

.field-row input[type="time"] {
  width: 118px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  font-family: var(--font);
  text-align: center;
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
  padding: 0 8px;
}

.field-row input[type="time"]:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
}

.note {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-faint);
  background: rgba(245, 197, 66, 0.07);
  border: 1px solid rgba(245, 197, 66, 0.22);
  border-radius: 14px;
  padding: 12px 16px;
}

/* ---------- 按钮 ---------- */
.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-secondary {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
}

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

/* ---------- 确认弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 14, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
  animation: fade-in 0.2s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-card {
  width: 100%;
  max-width: 340px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 26px 22px 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: pop-in 0.25s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-text {
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 22px;
  text-align: center;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-actions .btn {
  min-height: 52px;
}

/* ---------- 焦点可见性 ---------- */
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

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

  .screen {
    min-height: calc(100dvh - 48px);
    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);
  }

  .workout-card:hover {
    border-color: rgba(255, 255, 255, 0.16);
  }
}

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