:root {
  --tomato: #FF6B4A;
  --tomato-soft: #FFECE6;
  --leaf: #35A87C;
  --leaf-soft: #E6F6EF;
  --ink-1: #2B2B2B;
  --ink-2: #5A5A5A;
  --ink-3: #9A9A9A;
  --line: #ECECEC;
  --bg: #FBF7F2;
  --card: #FFFFFF;
  --radius: 20rpx;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink-1);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

.hidden { display: none !important; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
}
.topbar-left { display: flex; flex-direction: column; }
.topbar-date { font-size: 16px; font-weight: 600; }
.topbar-greet { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  border: none;
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.icon-btn:active { background: var(--tomato-soft); }

/* ---------------- 视图容器 ---------------- */
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 18px 18px;
}

/* ---------------- 设圈数 ---------------- */
.goal-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.goal-title { font-size: 26px; font-weight: 700; margin-bottom: 8px; }
.goal-sub { font-size: 13px; color: var(--ink-3); margin-bottom: 28px; }
.goal-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.goal-input {
  width: 140px;
  height: 150px;
  border: 3px solid var(--tomato);
  border-radius: 28px;
  text-align: center;
  font-size: 72px;
  font-weight: 700;
  color: var(--tomato);
  background: var(--card);
  outline: none;
}
.goal-unit { font-size: 22px; color: var(--ink-2); }
.goal-btns { width: 100%; display: flex; flex-direction: column; gap: 12px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  padding: 0 20px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  line-height: 1;
  white-space: nowrap;
  word-break: keep-all;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { opacity: 0.85; transform: scale(0.985); }
.btn-primary { background: var(--tomato); color: #fff; }
.btn-leaf { background: var(--leaf); color: #fff; }
.btn-ghost { background: #fff; color: var(--ink-2); border: 1.5px solid var(--line); }
.btn-block { width: 100%; }
.flex1 { flex: 1; min-width: 170px; }

/* ---------------- 主界面 ---------------- */
.top-progress {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin: 4px 0 14px;
  position: relative;
}
.top-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--tomato);
  transition: width 0.4s;
}
.top-progress-text {
  position: absolute;
  right: 0; top: -20px;
  font-size: 12px;
  color: var(--ink-3);
}

.dots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}
.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--line);
}
.dot.done { background: var(--tomato); }
.dot.now { background: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-soft); }

.stage { flex: 1; display: flex; flex-direction: column; }

/* 待开始 */
.idle-hero { display: flex; flex-direction: column; align-items: center; padding: 40px 0 30px; }
.idle-title { font-size: 24px; font-weight: 700; }
.idle-sub { font-size: 14px; color: var(--ink-3); margin-top: 6px; }

/* 圆环 */
.ring-wrap {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 16px auto 8px;
}
.ring-canvas { width: 280px; height: 280px; }
.ring-center {
  position: absolute; left: 0; top: 0;
  width: 280px; height: 280px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-time { font-size: 56px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring-phase { font-size: 15px; color: var(--ink-2); margin-top: 4px; }
.ring-task { font-size: 13px; color: var(--tomato); margin-top: 8px; max-width: 220px; text-align: center; }

/* 完成 */
.success-hero { display: flex; flex-direction: column; align-items: center; padding: 6px 0 18px; }
.success-badge {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--tomato-soft); color: var(--tomato);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 700;
  margin-bottom: 12px;
}
.success-title { font-size: 22px; font-weight: 700; }

.record-card, .slider-card, .ex-card {
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.record-label { font-size: 14px; color: var(--ink-2); margin-bottom: 10px; }
.record-input {
  width: 100%;
  min-height: 56px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  background: #fff;
}
.record-input:focus { border-color: var(--tomato); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  background: var(--tomato-soft);
  color: var(--tomato);
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.slider-head { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); }
.slider-val { color: var(--tomato); font-weight: 600; }
.slider { width: 100%; margin-top: 10px; accent-color: var(--tomato); }
.inherit-tip { font-size: 12px; color: var(--leaf); margin-top: 6px; }

/* 休息 */
.ex-head { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.ex-list { display: flex; flex-direction: column; gap: 10px; }
.ex-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
}
.ex-item .ex-flag {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff;
}
.ex-item.on { border-color: var(--leaf); background: var(--leaf-soft); }
.ex-item.on .ex-flag { background: var(--leaf); border-color: var(--leaf); }
.ex-name { flex: 1; font-size: 15px; }
.ex-item.on .ex-name { color: var(--leaf); text-decoration: line-through; }
.ex-encourage { font-size: 13px; color: var(--leaf); text-align: center; margin-top: 12px; min-height: 18px; }

.stage-actions { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.tip {
  border: none; background: none; color: var(--ink-3);
  font-size: 13px; text-align: center; cursor: pointer; padding: 6px;
}

/* ---------------- 日历 ---------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.cal-title { font-size: 18px; font-weight: 700; }
.cal-weekrow { display: grid; grid-template-columns: repeat(7,1fr); text-align: center; color: var(--ink-3); font-size: 12px; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; }
.cal-cell {
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 14px; position: relative; cursor: pointer;
}
.cal-cell.empty { cursor: default; }
.cal-cell.has { background: var(--tomato-soft); color: var(--tomato); font-weight: 600; }
.cal-cell .cal-dot { font-size: 10px; color: var(--tomato); margin-top: 2px; }
.cal-cell.today { box-shadow: 0 0 0 2px var(--leaf); }
.cal-detail { background: var(--card); border-radius: 16px; padding: 16px; margin-top: 14px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.cal-detail-day { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.cal-sess { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.cal-sess:last-child { border-bottom: none; }
.cal-sess .cs-task { font-weight: 600; }
.cal-sess .cs-meta { color: var(--ink-3); font-size: 12px; }
.cal-ex { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }
.cal-ex .ce-flag { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line); font-size: 11px; text-align: center; color: #fff; }
.cal-ex.on .ce-flag { background: var(--leaf); border-color: var(--leaf); }
.cal-ex.on { color: var(--leaf); }
.cal-block-label { font-size: 13px; color: var(--ink-2); margin: 12px 0 4px; font-weight: 600; }

/* ---------------- 设置 ---------------- */
.set-scroll { flex: 1; overflow-y: auto; }
.acc { background: var(--card); border-radius: 16px; margin-bottom: 12px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.acc-head { display: flex; align-items: center; padding: 16px; cursor: pointer; font-size: 16px; font-weight: 600; }
.acc-head .acc-sum { margin-left: auto; font-size: 12px; color: var(--ink-3); font-weight: 400; margin-right: 8px; }
.acc-arrow { color: var(--ink-3); transition: transform 0.2s; }
.acc.open .acc-arrow { transform: rotate(180deg); }
.acc-body { display: none; padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.acc.open .acc-body { display: block; }

.stepper-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.stepper-label { font-size: 15px; }
.stepper { display: flex; align-items: center; gap: 16px; }
.step-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid var(--line); background: #fff;
  font-size: 20px; color: var(--ink-1); cursor: pointer; line-height: 1;
}
.step-btn:active { background: var(--tomato-soft); }
.step-val { font-size: 18px; font-weight: 600; min-width: 28px; text-align: center; }

.line { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line-label { font-size: 15px; }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 3px; }
.seg-item {
  padding: 8px 14px; border-radius: 10px; font-size: 13px; color: var(--ink-2);
  cursor: pointer; white-space: nowrap;
}
.seg-item.on { background: #fff; color: var(--tomato); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.seg-block { margin-bottom: 12px; }
.week-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.week-tab {
  padding: 8px 12px; border-radius: 12px; background: var(--bg);
  font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.week-tab.on { background: var(--tomato); color: #fff; font-weight: 600; }

.try-row { display: flex; gap: 10px; margin-top: 12px; }
.try-btn {
  flex: 1; padding: 10px; border: 1.5px solid var(--line); background: #fff;
  border-radius: 14px; font-size: 13px; color: var(--tomato); cursor: pointer; white-space: nowrap;
}

.ex-add { display: flex; gap: 10px; margin-top: 12px; }
.ex-input {
  flex: 1; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 10px 14px; font-size: 14px; outline: none;
}
.ex-input:focus { border-color: var(--tomato); }
.add-btn {
  padding: 0 20px; background: var(--tomato); color: #fff;
  border: none; border-radius: 14px; font-size: 14px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.data-row { display: flex; gap: 12px; margin-bottom: 12px; }

/* 自定义开关 */
.switch {
  width: 50px; height: 28px; border-radius: 14px; background: var(--line);
  position: relative; cursor: pointer; display: inline-block; transition: background 0.2s;
}
.switch.on { background: var(--tomato); }
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  transition: left 0.2s;
}
.switch.on::after { left: 25px; }

/* ---------------- 弹窗 ---------------- */
.modal { position: absolute; inset: 0; z-index: 50; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 88%; max-width: 420px; background: #fff; border-radius: 18px; padding: 20px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-sub { font-size: 13px; color: var(--ink-3); margin: 6px 0 12px; }
.modal-textarea {
  width: 100%; height: 140px; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px; font-size: 13px; outline: none; resize: none; font-family: monospace;
}
.modal-actions { display: flex; gap: 12px; margin-top: 14px; }

/* ---------------- 轻提示 ---------------- */
.toast {
  position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%);
  background: rgba(0,0,0,0.82); color: #fff; padding: 10px 18px; border-radius: 20px;
  font-size: 14px; z-index: 60; max-width: 80%; text-align: center;
}

/* 窄窗（贴在电脑右侧）适配 */
@media (max-width: 380px) {
  .ring-wrap, .ring-canvas, .ring-center { width: 240px; height: 240px; }
  .ring-time { font-size: 48px; }
  .goal-input { width: 120px; height: 130px; font-size: 60px; }
}
