/* ===== base.css — 变量、重置、基础布局 ===== */

:root {
  /* iOS 扁平化配色（浅色） */
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --card-2: #f7f7fa;
  --separator: rgba(60, 60, 67, 0.12);

  --text: #1c1c1e;
  --text-2: #3c3c43;
  --text-3: #8e8e93;

  --accent: #007aff;        /* iOS 蓝 */
  --accent-weak: rgba(0, 122, 255, 0.12);
  --success: #34c759;
  --danger: #ff3b30;
  --warning: #ff9500;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.06), 0 6px 20px rgba(0, 0, 0, 0.05);
  --shadow-fab: 0 6px 16px rgba(0, 122, 255, 0.35);

  --space: 16px;
  --tabbar-h: 64px;
  --topbar-h: 52px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
  --font-num: "SF Pro Display", -apple-system, ui-rounded, system-ui, sans-serif;
}

* {
  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);
  color: var(--text);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: inherit;
  font-size: 16px; /* 防止 iOS 聚焦缩放 */
}

ul { list-style: none; }

/* ===== 应用外壳 ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

.topbar {
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ===== 舞台：首页 + 详情页（iOS 式推入） ===== */
.stage {
  position: relative;
  flex: 1;
  overflow: hidden;
}
.page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space);
  padding-bottom: calc(var(--safe-bottom) + 24px);
}

/* 首页默认可见，详情打开时向左轻微视差 */
.page-home {
  z-index: 1;
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1),
    filter 0.38s ease;
}
.page-home.is-behind {
  transform: translateX(-22%);
  filter: brightness(0.94) saturate(1.05);
}

/* 详情页：从右侧推入 */
.page-detail {
  z-index: 5;
  background: var(--bg);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1),
    visibility 0s linear 0.4s;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.12);
}
.page-detail.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1),
    visibility 0s linear 0s;
}

/* 顶部返回按钮 */
.nav-back {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 300;
  color: var(--accent);
  z-index: 2;
}
.nav-back[hidden] { display: none; }
.nav-back-arrow { line-height: 1; margin-top: -2px; }
.nav-back:active { opacity: 0.5; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 通用按钮 ===== */
.btn {
  height: 50px;
  padding: 0 22px;
  border-radius: var(--radius-md);
  font-size: 17px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, opacity 0.2s, background 0.2s;
  flex: 1;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--card-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--accent); font-weight: 500; }
.btn-danger { background: var(--danger); color: #fff; }
.btn.is-running { background: var(--warning); }

/* ===== Toast ===== */
.toast-wrap {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: rgba(30, 30, 32, 0.92);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-1);
  animation: toast-in 0.3s ease;
  max-width: 88%;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast.out { animation: toast-out 0.3s ease forwards; }
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-12px); }
}

/* ===== 模态框 ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  animation: fade-in 0.25s ease;
}
.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--bg-elevated);
  border-radius: 20px 20px 0 0;
  padding-bottom: calc(var(--safe-bottom) + 12px);
  animation: sheet-up 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--space);
  border-bottom: 0.5px solid var(--separator);
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-btn { font-size: 16px; color: var(--accent); padding: 4px 6px; }
.modal-btn-strong { font-weight: 700; }
.modal-body { padding: 20px var(--space); }
