:root {
  --bg: #faf7f1;
  --card: #ffffff;
  --ink: #2e2b27;
  --ink-soft: #5c564e;
  --muted: #9b948a;
  --line: #eee7db;
  --primary: #e8833a;
  --primary-deep: #d46f28;
  --primary-soft: #fdf0e3;
  --teal: #3e9d8f;
  --teal-soft: #e6f4f1;
  --danger: #d95f5f;
  --danger-soft: #fbeaea;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 28px rgba(84, 62, 38, 0.08);
  --shadow-lg: 0 18px 48px rgba(84, 62, 38, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(232, 131, 58, 0.35); outline-offset: 1px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: env(safe-area-inset-top);
  background: rgba(250, 247, 241, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 20px;
  background: linear-gradient(135deg, #f6b26b, var(--primary));
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(232, 131, 58, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; letter-spacing: 0.02em; }
.brand-text small { font-size: 12px; color: var(--muted); }

.nav {
  display: flex;
  gap: 4px;
  background: #f1ece2;
  padding: 4px;
  border-radius: 999px;
}
.nav-item {
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-soft);
  transition: all 0.2s ease;
  font-weight: 500;
}
.nav-item:hover { color: var(--ink); }
.nav-item.active {
  background: #fff;
  color: var(--primary-deep);
  box-shadow: 0 2px 8px rgba(84, 62, 38, 0.12);
  font-weight: 600;
}
/* pet switcher */
.pet-switch-wrap { position: relative; flex: none; }
.pet-switch {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--ink);
  box-shadow: 0 2px 8px rgba(84, 62, 38, 0.08);
  cursor: pointer; transition: box-shadow .15s ease;
}
.pet-switch:hover { box-shadow: 0 4px 14px rgba(84, 62, 38, 0.16); }
.pet-switch-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 16px;
  background: var(--primary-soft); overflow: hidden; flex: none;
}
.pet-switch-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pet-switch-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pet-switch-caret { color: var(--muted); font-size: 12px; }
.pet-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 210px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 12px 32px rgba(84, 62, 38, 0.18);
  padding: 6px; z-index: 60;
}
.pet-menu-list { display: flex; flex-direction: column; gap: 2px; }
.pet-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; font-size: 14px; font-weight: 500;
  width: 100%; text-align: left; color: var(--ink);
}
.pet-menu-item:hover { background: #f7f2e9; }
.pet-menu-item.on { color: var(--primary-deep); font-weight: 700; }
.pet-menu-avatar {
  width: 28px; height: 28px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; font-size: 15px; background: var(--primary-soft); flex: none;
}
.pet-menu-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pet-menu-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pet-menu-check { color: var(--primary); font-weight: 800; }
.pet-menu-add {
  width: 100%; margin-top: 4px; padding: 9px 10px;
  border-top: 1px solid var(--line); color: var(--primary-deep);
  font-weight: 600; font-size: 14px; text-align: left;
}
.pet-menu-add:hover { color: var(--primary); }

/* pet management */
.pet-manage-list { display: flex; flex-direction: column; gap: 10px; }
.pet-manage-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.pet-manage-row:hover { border-color: rgba(232, 131, 58, 0.55); box-shadow: 0 2px 10px rgba(232, 131, 58, 0.08); }
.pet-manage-row.on { border-color: rgba(232, 131, 58, 0.5); background: #fff8ef; }
.pet-edit-hint { font-size: 12px; margin-left: 6px; opacity: .75; }
#s-pet-edit { scroll-margin-top: 76px; }
.dog-avatar.sm { width: 44px; height: 44px; border-radius: 12px; font-size: 22px; flex: none; }
.pet-manage-info { flex: 1; min-width: 0; }
.pet-manage-name { font-weight: 700; font-size: 15px; }
.pet-manage-cur {
  font-size: 11px; color: var(--primary-deep); background: var(--primary-soft);
  padding: 2px 8px; border-radius: 999px; margin-left: 6px; font-weight: 600;
}
.pet-manage-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }


/* ---------- 布局 ---------- */
.container { max-width: 1040px; margin: 0 auto; padding: 28px 20px calc(80px + env(safe-area-inset-bottom)); }

.view { display: none; animation: fadeUp 0.28s ease; }
.view.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  border: 1px solid rgba(238, 231, 219, 0.6);
}

.card + .card { margin-top: 18px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title .ico { font-size: 18px; }
.card-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- 概览 ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  margin-bottom: 18px;
}

.dog-card {
  background: linear-gradient(135deg, #fff8ef, #ffffff);
  border: 1px solid #f3e6d2;
}

.dog-avatar {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  font-size: 34px;
  background: var(--primary-soft);
  border-radius: 18px;
}
.avatar-edit { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.avatar-open { cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.avatar-open:hover { transform: scale(1.06); box-shadow: 0 6px 16px rgba(232, 131, 58, 0.28); }
.avatar-edit .dog-avatar { width: 76px; height: 76px; border-radius: 20px; font-size: 38px; }
.dog-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

.dog-name { font-size: 22px; font-weight: 800; }

.age-line { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
.age-num { font-size: 30px; font-weight: 800; color: var(--primary-deep); }
.age-unit { font-size: 14px; color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--teal-soft);
  color: #2b7d72;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.ring-card { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-label { font-size: 13px; color: var(--muted); margin-top: 10px; }
.ring-sub { font-size: 12px; color: var(--muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 18px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}
.stat-num { font-size: 26px; font-weight: 800; color: var(--ink); }
.stat-num small { font-size: 14px; font-weight: 600; color: var(--muted); }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.week-chart { display: flex; align-items: flex-end; gap: 8px; height: 90px; padding: 6px 0; }
.week-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week-bar {
  width: 100%;
  max-width: 30px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #f6b26b, var(--primary));
  min-height: 3px;
  transition: height 0.4s ease;
}
.week-bar.today { box-shadow: 0 0 0 3px var(--primary-soft); }
.week-day { font-size: 11px; color: var(--muted); }

/* ---------- 列表项 ---------- */
.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fbf8f2;
  border: 1px solid var(--line);
}
.item-row + .item-row { margin-top: 8px; }

.item-main { flex: 1; min-width: 0; }
.item-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-weight: 600;
  font-size: 14.5px;
  overflow-wrap: anywhere;
  min-width: 0;
}
.item-name .tag { margin-left: 0; flex: none; }
.tag { display: inline-block; font-size: 10px; line-height: 1.5; padding: 0 7px; border-radius: 999px; vertical-align: 1px; font-weight: 600; letter-spacing: .2px; white-space: nowrap; }
.tag i { font-style: normal; }
.tag-M1 { background: #fdeeda; color: #c05f1e; }
.tag-M2 { background: #e7effe; color: #3a6fd8; }
.tag-M3 { background: #e6f6ec; color: #2e9e5b; }
.tag-M4 { background: #f0e9fb; color: #7a4fd0; }
.tag-M5 { background: #e0f4f4; color: #159494; }
.tag-M6 { background: #fde8e8; color: #d04848; }
.tag-neutral { background: #f0ece3; color: #9a9081; }
.tag-new { background: #ffe9d6; color: #d4742a; }
.tag-stage { background: #f0ece3; color: #9a9081; }
.item-desc { font-size: 12.5px; color: var(--muted); }
.tips-box { font-size: 12.5px; line-height: 1.65; color: var(--muted); margin-top: 7px; padding: 8px 11px; border-radius: 8px; background: #fdf8ef; border: 1px solid #f3e9d8; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: break-word; }
.item-right { flex: none; }
.item-row[hidden] { display: none; }

.item-row.is-high { border-color: #eeddcc; box-shadow: inset 3px 0 0 rgba(232, 131, 58, 0.5); }
.item-row.is-low { background: #f8f6f1; border-color: #ece7dd; box-shadow: inset 3px 0 0 #d8d0c4; }
.item-row.is-low .item-name { font-weight: 500; color: var(--muted); }
.item-row.is-low .item-desc { color: #b4ada2; }
.item-row.is-low .record-status { border-color: #ddd5c9; }
.item-row.done { border-color: #cfe6e1; background: #f0faf8; }
.item-row.done .record-status { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }
.item-row.done .item-name { color: var(--muted); }

.item-row.postponed {
  opacity: 0.62;
  filter: grayscale(0.55);
  background: #f1eee7;
  border: 1px dashed #d5cdbf;
  box-shadow: none;
}
.item-row.postponed .item-name { color: var(--muted); font-weight: 500; }
.item-row.postponed .item-desc { color: #b0a99c; }
.item-row.postponed .record-status { border-color: #d5cdbf; color: #9a9081; background: #fff; }
.item-row.postponed .record-status:hover { border-color: var(--primary); color: var(--primary-deep); background: var(--primary-soft); }
.item-row.postponed .item-right .chip { background: #e6e1d6; color: #9a9081; }

.priority-btn {
  flex: none;
  min-width: 46px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.priority-btn.high { color: var(--primary-deep); background: var(--primary-soft); }
.priority-btn.high:hover { background: #fbe3cc; }
.priority-btn.low { color: #8f887c; background: #f1ece2; }
.priority-btn.low:hover { background: #e9e1d4; }

.priority-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 0 14px;
  padding: 10px 12px;
  background: #fbf8f2;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.priority-note { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.priority-filter { display: flex; gap: 4px; }
.filter-btn {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary-deep); }
.filter-btn.on { color: var(--primary-deep); background: var(--primary-soft); border-color: var(--primary); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip .cdot { width: 8px; height: 8px; border-radius: 50%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(232, 131, 58, 0.3); }
.btn-primary:hover { background: var(--primary-deep); transform: translateY(-1px); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-soft); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary-deep); }
.btn-soft { background: var(--primary-soft); color: var(--primary-deep); }
.btn-soft:hover { background: #fbe3cc; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { background: #f6d6d6; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s ease;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }

.radio-row { display: flex; gap: 8px; }
.radio-pill {
  flex: 1;
  text-align: center;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: #fff;
  transition: all 0.15s ease;
}
.radio-pill:hover { border-color: var(--primary); }
.radio-pill.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-deep); }

/* ---------- 计划 ---------- */
.section-gap { height: 26px; }

.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.stage-card { border-top: 4px solid var(--stage-color, var(--primary)); transition: transform 0.18s ease, box-shadow 0.18s ease; }
.stage-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.stage-title { font-size: 16.5px; font-weight: 800; }
.stage-week {
  font-size: 12px;
  font-weight: 700;
  color: var(--stage-color, var(--primary));
  background: color-mix(in srgb, var(--stage-color, var(--primary)) 12%, #fff);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.stage-desc { font-size: 12.5px; color: var(--muted); margin: 6px 0 12px; }

.mini-list { display: flex; flex-direction: column; gap: 6px; }
.mini-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 9px;
  background: #fbf8f2;
}
.mini-item .cdot { flex: none; }
.mini-item .mini-name { flex: 1; min-width: 0; }
.mini-item .record-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  padding: 2px 8px;
  border-radius: 7px;
}
.mini-item .record-link:hover { background: var(--teal-soft); }

/* ---------- 时间轴 ---------- */
.timeline-wrap { overflow-x: auto; padding-bottom: 8px; }
.timeline { min-width: 680px; position: relative; }
.tl-row { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 14px; align-items: center; margin-bottom: 12px; }
.tl-meta { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tl-title { font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.35; overflow-wrap: anywhere; }
.tl-range { font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }
.tl-track {
  position: relative;
  height: 26px;
  background-color: #f7f2e9;
  background-image: repeating-linear-gradient(to right, transparent 0, transparent calc((100% / 13) - 1px), #eadfce calc((100% / 13) - 1px), #eadfce calc(100% / 13));
  border-radius: 999px;
  overflow: visible;
}
.tl-bar {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 999px;
  min-width: 10px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.10), 0 2px 6px rgba(84, 62, 38, 0.12);
}
.tl-bar.current { outline: 3px solid rgba(232, 131, 58, 0.35); outline-offset: 1px; }
.tl-now {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  margin-left: -1px;
  background: var(--primary);
  border-radius: 2px;
  opacity: 0.9;
  z-index: 1;
}
.tl-axis { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 14px; margin-top: 4px; }
.tl-axis-marks { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); }

/* ---------- 自定义规划 ---------- */
.plan-card { display: flex; flex-direction: column; gap: 12px; }
.plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.plan-title { font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.plan-week { font-size: 12px; color: var(--muted); }
.plan-actions { display: flex; gap: 6px; }
.plan-colorbar { height: 5px; border-radius: 999px; margin-top: 2px; }

/* ---------- 记录 ---------- */
.record-group { margin-bottom: 16px; }
.record-group-date {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  margin: 14px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.record-group-date::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.record-item { display: flex; align-items: center; gap: 12px; }
.record-status {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 14px;
  background: #fff;
  border: 1.5px solid var(--line);
  color: var(--muted);
  transition: all 0.15s ease;
}
.record-item.done .record-status { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }
.record-item.done .record-name { text-decoration: line-through; color: var(--muted); }
.record-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.record-note { font-size: 12.5px; color: var(--ink-soft); background: #fbf8f2; padding: 6px 10px; border-radius: 8px; margin-top: 4px; }
.record-minutes {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-deep);
  background: var(--primary-soft);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.icon-btn {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 14px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.icon-btn:hover { background: #f4efe6; color: var(--ink); }

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}
.empty .empty-ico { font-size: 40px; margin-bottom: 10px; }
.empty p { font-size: 13.5px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(46, 40, 32, 0.42);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  animation: fadeIn 0.2s ease;
}
.modal-mask[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  max-height: calc(100dvh - 40px);
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
  padding: 24px;
  margin: auto;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.modal-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.item-editor { display: flex; flex-direction: column; gap: 8px; }
.item-editor-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slideUp 0.25s ease;
  white-space: nowrap;
}
.toast[hidden] { display: none; }

/* ---------- 设置 ---------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: none; }
.setting-name { font-size: 14.5px; font-weight: 600; }
.setting-desc { font-size: 12.5px; color: var(--muted); }

.about-line { font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.about-line .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }

/* ---------- 计划选择与切换 ---------- */
.plan-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.choice-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 30px 18px; border-radius: 16px;
  border: 1.5px solid var(--line); background: #fff;
  transition: all 0.18s ease;
}
.choice-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.choice-ico { font-size: 34px; }
.choice-title { font-size: 16.5px; font-weight: 800; }
.choice-desc { font-size: 12.5px; color: var(--muted); }

.plan-tabs-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.plan-tabs { display: flex; gap: 4px; background: #f1ece2; padding: 4px; border-radius: 12px; }
.plan-tab { padding: 7px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 700; color: var(--muted); transition: all 0.15s ease; }
.plan-tab.on { background: #fff; color: var(--primary-deep); box-shadow: 0 1px 4px rgba(84, 62, 38, 0.12); }

.week-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.week-grid .card, .stage-grid .card, .hero .card { margin-top: 0; }
.week-card { border-top: 4px solid var(--stage-color, var(--primary)); }
.week-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.week-title { font-size: 15px; font-weight: 800; }
.week-pct { font-size: 12.5px; font-weight: 800; color: var(--stage-color, var(--primary)); }
.day-dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.day-dot {
  aspect-ratio: 1; border-radius: 10px;
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  background: #f1ece2; display: grid; place-items: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.day-dot:hover { transform: scale(1.1); box-shadow: var(--shadow); }
.day-dot.part { background: color-mix(in srgb, var(--stage-color, var(--primary)) 30%, #fff); color: var(--ink); }
.day-dot.full { background: var(--stage-color, var(--primary)); color: #fff; }
.day-dot.today { outline: 2px solid var(--primary); outline-offset: 1px; }

.plan-item { background: #fbf8f2; }
.plan-item .record-status { width: 24px; height: 24px; font-size: 11px; }
.plan-item.done .mini-name { text-decoration: line-through; color: var(--muted); }
.plan-item-desc { font-size: 11.5px; color: var(--muted); }

.chip.rec-goto { cursor: pointer; transition: all 0.15s ease; }
.chip.rec-goto:hover { background: var(--teal-soft); color: var(--teal); border-color: var(--teal); }

.modal-goal {
  font-size: 12.5px; color: var(--ink-soft);
  background: #fbf8f2; border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 10px; margin-bottom: 14px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  input, select, textarea { font-size: 16px; }
  .hero { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .container { padding: 18px 14px calc(70px + env(safe-area-inset-bottom)); }
  .form-grid { grid-template-columns: 1fr; }
  .topbar-inner { padding: 10px 14px; }
  .nav-item { padding: 6px 13px; font-size: 13px; }
  .priority-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .item-row { flex-wrap: wrap; row-gap: 8px; }
  .item-main { flex: 1 1 auto; min-width: 120px; }
  .item-actions { margin-left: auto; }
}

/* 安装提示 */
.install-bar {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e8833a;
  color: #fff;
  padding: 6px 8px 6px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
  z-index: 1300;
  font-size: 14px;
  white-space: nowrap;
}
.install-bar[hidden] { display: none; }
.install-btn {
  background: #fff;
  color: #e8833a;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.install-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
}
.install-guide-mask {
  position: fixed; inset: 0; z-index: 1500;
  background: rgba(40, 28, 14, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; box-sizing: border-box;
}
.install-guide {
  width: min(100%, 360px); background: #fffdf8; border-radius: 18px;
  padding: 24px 22px; box-shadow: 0 14px 44px rgba(0, 0, 0, 0.28);
  box-sizing: border-box;
}
.install-guide-title { font-size: 17px; font-weight: 800; text-align: center; }
.install-guide-sub { font-size: 13px; color: var(--muted); text-align: center; margin: 8px 0 18px; line-height: 1.55; }
.install-step { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; }
.install-step-ico {
  width: 38px; height: 38px; flex: none; border-radius: 11px;
  background: var(--primary-soft); color: var(--primary-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700;
}
.install-step-txt { font-size: 13.5px; line-height: 1.55; padding-top: 8px; }

/* 登录页 */
.auth {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #fdf7ee, #f6e7d3);
  padding: 16px;
}
.auth[hidden] { display: none; }
.auth-card {
  width: min(100%, 420px);
  box-sizing: border-box;
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px 24px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .08);
  text-align: center;
}
.auth-logo { font-size: 44px; line-height: 1; }
.auth-title { font-size: 20px; font-weight: 700; margin-top: 10px; color: #3d2f22; }
.auth-sub { font-size: 13px; color: #8a7a68; margin-top: 4px; margin-bottom: 18px; }
.auth-tabs {
  display: flex;
  background: #f5efe6;
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 18px;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  border-radius: 999px;
  font-size: 14px;
  color: #8a7a68;
  cursor: pointer;
}
.auth-tab.active { background: #fff; color: #e8833a; font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.auth-field { text-align: left; margin-bottom: 14px; }
.auth-field label { display: block; font-size: 12px; color: #8a7a68; margin-bottom: 6px; }
.auth-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #e8ddcd;
  border-radius: 10px;
  font-size: 14px;
  background: #fdfbf8;
  outline: none;
}
.auth-field input:focus { border-color: #e8833a; background: #fff; }
.auth-btn { width: 100%; margin-top: 6px; }
.auth-msg { min-height: 20px; font-size: 13px; margin-top: 10px; }
.auth-msg.err { color: #d96c6c; }
.auth-msg.ok { color: #3e9d8f; }
.auth-note { font-size: 12px; color: #b0a28e; margin-top: 10px; }
.auth-welcome-title { font-size: 17px; font-weight: 800; color: #3d2f22; margin: 6px 0 6px; }
.auth-welcome-sub { font-size: 13px; color: #8a7a68; margin-bottom: 20px; line-height: 1.6; }
.auth-link {
  display: block; margin: 14px auto 0; border: none; background: transparent;
  color: #b0875f; font-size: 13px; cursor: pointer; text-decoration: underline; padding: 4px 8px;
}
.auth-link:hover { color: var(--primary-deep); }

/* ---------- 周计划：查看与编辑 ---------- */
.week-open { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.week-open:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(61, 47, 34, .1); }
.week-custom-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  color: #e8833a;
  background: #fdeee0;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
  vertical-align: 2px;
}
.week-custom-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-top: 4px solid var(--stage-color, var(--primary));
  background: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}
.week-custom-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(61, 47, 34, .1); }
.week-custom-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-custom-pct { font-size: 13px; font-weight: 800; color: var(--stage-color, var(--primary)); flex: none; }

.week-edit-head { margin-bottom: 10px; }
.w-title, .w-goal {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fdfbf8;
  outline: none;
  margin-bottom: 8px;
  font-family: inherit;
}
.w-title:focus, .w-goal:focus, .w-focus:focus, .w-task:focus, .w-dur:focus, .w-tips:focus { border-color: var(--primary); background: #fff; }
.week-edit-day { padding: 6px 0 2px; }
.week-edit-day-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.w-focus {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13.5px;
  background: #fdfbf8;
  outline: none;
  font-family: inherit;
}
.week-edit-task { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.w-slot { font-size: 12px; font-weight: 700; color: var(--muted); width: 40px; flex: none; }
.w-task, .w-dur, .w-tips {
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
  background: #fdfbf8;
  outline: none;
  font-family: inherit;
}
.w-task { flex: 1; min-width: 0; }
.w-dur { width: 74px; flex: none; }
.w-tips { width: 100%; margin-bottom: 10px; }

/* 周弹窗分页布局：固定头部 + 滚动内容 + 固定底部 */
.modal.modal-week {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.week-head-wrap { padding: 20px 24px 0; flex: none; }
.week-head-wrap .modal-title { margin-bottom: 12px; }
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0 2px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.week-nav-ind { font-size: 13px; color: var(--muted); font-weight: 600; }
.week-pages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 24px 4px; }
.week-page { padding: 4px 0 8px; }
.week-foot {
  flex: none;
  margin-top: 0;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--line);
  background: #fff;
}
/* 周表现弹窗：先看表现，点编辑再修改 */
.week-perf { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 24px 16px; }
.week-perf-sub { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.wp-days { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.wp-day { padding: 10px 12px; border-radius: 12px; background: #faf7f0; border: 1px solid var(--line); }
.wp-day.today { background: #fff7ec; border-color: #f0c48f; }
.wp-day-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.wp-day-meta { color: var(--muted); }
.wp-day-count { margin-left: auto; font-weight: 700; }
.wp-day-min { color: var(--muted); flex: none; }
.wp-day-tasks {
  margin-top: 7px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #8a7f6d;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.wp-bar { height: 6px; margin-top: 8px; border-radius: 999px; background: #efe9dd; overflow: hidden; }
.wp-bar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #f6b26b, #e8833a); transition: width .4s ease; }
.wp-empty { font-size: 13px; color: var(--muted); padding: 18px 4px; }
/* mobile pet switch */
@media (max-width: 640px) {
  .pet-switch-name { display: none; }
  .pet-switch { padding: 5px; gap: 4px; }
  .pet-menu { position: fixed; left: 12px; right: 12px; top: 64px; }
}


/* ---------- 概览行操作：删除 / 推迟 ---------- */
.item-actions { flex: none; display: flex; gap: 4px; }
.icon-btn.mini { width: 26px; height: 26px; font-size: 12px; border-radius: 8px; }
.icon-btn.mini.task-del:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.mini.task-post:hover { background: #fdf0e3; color: var(--primary-deep); }

.tag-post { background: var(--danger-soft); color: var(--danger); }
.tag-post i { font-style: normal; }

/* ---------- 回收站 ---------- */
.trash-card { border: 1.5px dashed #e5d3cc; background: #fffaf8; }
.trash-open { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; padding: 2px; }
.trash-head { display: flex; align-items: center; gap: 10px; }
.trash-title { font-size: 15px; font-weight: 800; }
.trash-sub { font-size: 12px; font-weight: 700; color: var(--danger); }
.trash-peek { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-more { font-size: 12px; font-weight: 700; color: var(--primary-deep); }
.trash-list { display: flex; flex-direction: column; gap: 8px; }
.trash-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fbf8f2;
  border: 1px solid var(--line);
}
.trash-item + .trash-item { margin-top: 0; }


/* ---------- 训练模块 ---------- */
.mods-line { display: flex; align-items: center; gap: 6px; margin-top: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.mods-chip {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .3px;
  background: var(--primary-soft); color: var(--primary-deep); cursor: pointer;
  border: 1px solid rgba(232, 131, 58, .18); transition: all .15s ease;
}
.mods-chip:hover { filter: brightness(.97); }
.mods-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mods-check {
  display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #fffdf9; cursor: pointer; font-size: 13px;
}
.mods-check:hover { border-color: rgba(232, 131, 58, .4); }
.mods-check input { accent-color: var(--primary); width: 15px; height: 15px; flex: none; }
.mods-check-name { line-height: 1.35; }
.mods-badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 34px; padding: 2px 7px; border-radius: 7px; font-size: 11px; font-weight: 800; letter-spacing: .4px;
}
.mods-modal-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.mods-modal-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); background: #fffdf9; border: 1px solid var(--line); }
.mods-modal-name { font-weight: 600; font-size: 14px; }
.mods-modal-note { margin-left: auto; font-size: 12px; color: var(--muted); flex: none; }

/* ===== 月历视图 ===== */
.cal-section { margin-top: 0; }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-title { font-weight: 700; font-size: 15px; flex: 1; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; min-width: 0; }
.cal-cell { min-height: 60px; min-width: 0; max-width: 100%; overflow: hidden; border-radius: 10px; border: 1px solid var(--line); background: #fffdf8; padding: 5px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; text-align: left; font-family: inherit; box-sizing: border-box; }
.cal-cell.empty { border: none; background: transparent; cursor: default; min-height: 0; }
.cal-cell.today { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(232, 131, 58, .18); }
.cal-cell.past { background: #f6f3ec; }
.cal-cell.gold { border-color: #d9a92e; box-shadow: 0 0 0 2px rgba(217, 169, 46, .25); }
.cal-cell .cal-num { font-size: 11.5px; font-weight: 700; color: var(--ink); flex: none; }
.cal-cell.past .cal-num { color: var(--muted); }
.cal-cell:not(.empty):hover { border-color: var(--primary); }
.cal-dots { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; min-height: 12px; margin-top: 2px; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.cal-more { font-size: 10px; font-weight: 700; color: var(--muted); line-height: 1; }
.cal-mark { font-size: 12px; text-align: center; margin-top: 2px; }
.cal-rest { font-size: 11px; color: #b8b0a2; text-align: center; margin-top: 2px; }
.cal-detail-empty { font-size: 12.5px; color: var(--muted); padding: 6px 0; }
.week-abs { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* ===== 能力快测 ===== */
.qt-group { margin-top: 14px; }
.qt-group-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; margin-bottom: 8px; }
.qt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.qt-item { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: #fffdf8; cursor: pointer; line-height: 1.35; }
.qt-item:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.qt-item input { accent-color: var(--primary); width: 15px; height: 15px; flex: none; margin-top: 1px; }