:root {
  /* 阳光暖色主题（UDO 风：杏棕→奶油渐变 + 琥珀橙） */
  --bg: #f9f8f0;
  --bg-grad: linear-gradient(180deg, #ecc49b 0%, #f6ecdd 42%, #f9f8f0 100%);
  --card: #fdf8ee;
  --card-2: #f8f0e1;
  --separator: rgba(150, 110, 70, 0.16);
  --text: #3a240d;
  --text-2: #9a7f62;
  --text-3: #dcc6ab;
  --check-border: #dcb287;
  --accent: #f09d12;            /* 琥珀橙（主色） */
  --accent-soft: rgba(240, 157, 18, 0.14);
  --green: #36b37e;             /* 备用 */
  --red: #ff5e5b;               /* 删除：珊瑚红 */
  --orange: #ffb02e;            /* 中优先级：琥珀 */
  --low: #ffd45e;               /* 低优先级：暖黄 */
  --gray: #9a7f62;
  --nav-blur: rgba(249, 240, 226, 0.82);
  --shadow: 0 1px 3px rgba(150, 100, 50, 0.08), 0 10px 28px rgba(200, 140, 70, 0.10);
  --radius: 16px;
  --radius-lg: 22px;
  --title-font: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191410;
    --bg-grad: linear-gradient(180deg, #33261a 0%, #241c14 45%, #191410 100%);
    --card: #2e251c;
    --card-2: #292017;
    --separator: rgba(255, 200, 150, 0.14);
    --text: #fbeee1;
    --text-2: #b7a592;
    --text-3: #5a4d42;
    --check-border: #6f5a41;
    --accent: #ffb340;
    --accent-soft: rgba(255, 179, 64, 0.18);
    --green: #5fd18a;
    --red: #ff6b5e;
    --orange: #ffbf4d;
    --low: #ffd97a;
    --nav-blur: rgba(41, 32, 23, 0.8);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 12px 32px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-grad, var(--bg));
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

/* ---------- 顶部导航 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--nav-blur);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
}
.nav-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 12px;
}
.title {
  font-family: var(--title-font);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 2px;
  margin: 0;
}
.title-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  margin-left: 2px;
}
.title-btn {
  display: flex; align-items: center; gap: 4px;
  border: none; background: transparent; padding: 0;
  color: var(--text); cursor: pointer;
}
.title-btn:active { opacity: 0.5; }
.title-chevron { color: var(--text-2); margin-top: 4px; }
.nav-action {
  width: 40px; height: 40px;
  border: none; background: transparent; color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer; transition: background 0.15s;
}
.nav-action:active { background: var(--accent-soft); }

/* 悬浮新建按钮（FAB） */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 16;
  width: 58px; height: 58px;
  border: none; border-radius: 50%;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 20px rgba(240, 157, 18, 0.45), 0 2px 6px rgba(150, 90, 20, 0.25);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.92); }

/* ---------- 分段控件（药丸式） ---------- */
.segmented {
  max-width: 480px;
  margin: 14px auto 6px;
  display: flex;
  gap: 8px;
  background: transparent;
  padding: 0;
  margin-left: 16px; margin-right: 16px;
  position: relative;
}
.segmented button {
  flex: 0 0 auto;
  border: none;
  background: var(--card);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: color 0.2s, background 0.2s;
  box-shadow: 0 1px 4px rgba(180, 130, 70, 0.12);
}
.segmented .thumb { display: none; }
.segmented button.active { background: var(--accent); color: #fff; }

/* ---------- 列表 ---------- */
.list {
  margin: 10px 16px 0;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.row-item {
  position: relative;
  overflow: hidden;
  border-bottom: 0.5px solid var(--separator);
  touch-action: pan-y;
}
.row-item:last-child { border-bottom: none; }
.row-item .bg-delete {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 80px;
  background: var(--red);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}
.row-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 13px 16px;
  background: var(--card);
  transition: transform 0.18s ease;
  will-change: transform;
}

/* 勾选方块（UDO 风圆角方块） */
.check {
  flex: 0 0 auto;
  width: 23px; height: 23px;
  border-radius: 7px;
  border: 2px solid var(--check-border);
  margin-right: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
}
.check svg { width: 14px; height: 14px; opacity: 0; transform: scale(0.5); transition: opacity 0.18s, transform 0.18s; color: #fff; }
.task.done .check { border-color: var(--accent); background: var(--accent); }
.task.done .check svg { opacity: 1; transform: scale(1); }

.task-body { flex: 1; min-width: 0; }
.task-title {
  font-size: 17px;
  line-height: 1.3;
  word-break: break-word;
  transition: color 0.18s;
}
.task.done .task-title { color: var(--text-2); text-decoration: line-through; }
.task-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 3px;
  font-size: 13px; color: var(--text-2);
}
.task-meta .dot { width: 6px; height: 6px; border-radius: 50%; }
.p-none { background: var(--text-3); }
.p-low  { background: var(--low); }
.p-mid  { background: var(--orange); }
.p-high { background: var(--red); }
.pill {
  font-size: 12px; padding: 1px 7px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  color: var(--text-2);
  padding: 80px 20px;
}
.empty-icon { color: var(--text-3); margin-bottom: 12px; }
.empty p { font-size: 18px; font-weight: 600; color: var(--text); margin: 0 0 6px; }
.empty span { font-size: 14px; }

/* ---------- 底部操作栏 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 15;
  max-width: 480px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: var(--nav-blur);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
  font-size: 14px;
}
.tabbar-count { color: var(--text-2); font-weight: 500; }
.tabbar-clear {
  border: none; background: transparent; color: var(--accent);
  font-size: 14px; font-weight: 600; cursor: pointer; padding: 4px 0;
}
.tabbar-clear:disabled { color: var(--text-3); cursor: default; }

/* ---------- 底部 Sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,0.4);
  opacity: 0; transition: opacity 0.3s;
}
.sheet-backdrop.show { opacity: 1; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  max-width: 480px; margin: 0 auto;
  background: var(--card-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet.show { transform: translateY(0); }
.sheet-grabber {
  width: 36px; height: 5px; border-radius: 3px;
  background: var(--text-3);
  margin: 10px auto 4px;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px 12px;
  border-bottom: 0.5px solid var(--separator);
}
.sheet-title { font-size: 17px; font-weight: 600; margin: 0; }
.sheet-btn {
  border: none; background: transparent;
  font-size: 17px; cursor: pointer; padding: 4px 2px;
}
.sheet-cancel { color: var(--accent); }
.sheet-done { color: var(--accent); font-weight: 600; }
.sheet-done:disabled { color: var(--text-3); }

.sheet-body { padding: 12px 16px 24px; }
.field { margin-bottom: 12px; }
.field input[type="text"] {
  width: 100%;
  border: none;
  background: var(--card);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 17px;
  color: var(--text);
  outline: none;
}
.field input::placeholder { color: var(--text-3); }
.field-group {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}
.field.row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 0.5px solid var(--separator);
  margin-bottom: 0;
}
.field[hidden] { display: none; }
.field.row.last { border-bottom: none; }
.field-label { font-size: 17px; color: var(--text); }
.field-value {
  border: none; background: transparent;
  font-size: 16px; color: var(--text-2);
  text-align: right; outline: none;
  color-scheme: light dark;
}
.priority { display: flex; gap: 6px; }
.priority button {
  border: 1px solid var(--separator);
  background: transparent;
  color: var(--text-2);
  font-size: 13px; font-weight: 600;
  padding: 5px 11px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.priority button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* iOS 开关 */
.switch { position: relative; display: inline-block; width: 51px; height: 31px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0;
  background: var(--text-3);
  border-radius: 16px;
  transition: background 0.22s;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.22s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }

/* 列表选择面板 */
.lists-body { padding: 8px 0 24px; }
.lists { margin: 0 16px; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-row {
  position: relative;
  overflow: hidden;
  border-bottom: 0.5px solid var(--separator);
  touch-action: pan-y;
}
.list-row:last-child { border-bottom: none; }
.list-row .bg-delete {
  position: absolute; top: 0; right: 0; bottom: 0; width: 80px;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}
.list-inner {
  position: relative; z-index: 2;
  display: flex; align-items: center;
  width: 100%; padding: 13px 14px;
  background: var(--card);
  transition: transform 0.18s ease;
  will-change: transform;
  cursor: pointer;
}
.list-dot { width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto; margin-right: 12px; }
.list-name { flex: 1; font-size: 17px; color: var(--text); }
.list-count { font-size: 15px; color: var(--text-2); margin-right: 6px; }
.list-check { width: 20px; height: 20px; color: var(--accent); flex: 0 0 auto; opacity: 0; }
.list-row.current .list-check { opacity: 1; }

.new-list {
  margin: 14px 16px 0;
  background: var(--card); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.new-list input {
  width: 100%; border: none; background: transparent;
  font-size: 17px; color: var(--text); outline: none; padding: 2px 0 10px;
}
.new-list input::placeholder { color: var(--text-3); }
.color-picker { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.color-picker .c-dot {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; transition: transform 0.12s;
}
.color-picker .c-dot.active { border-color: var(--text); transform: scale(1.08); }
.new-list-btn {
  width: 100%; border: none; background: var(--accent-soft); color: var(--accent);
  font-size: 16px; font-weight: 600; padding: 11px 0; border-radius: 10px; cursor: pointer;
}
.new-list-btn:active { opacity: 0.7; }
.sheet-spacer { width: 40px; display: inline-block; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.row-item.removing { animation: slideOut 0.25s ease forwards; }
@keyframes slideOut {
  to { opacity: 0; transform: translateX(-30px); height: 0; padding-top: 0; padding-bottom: 0; }
}

/* 提示气泡 */
.toast {
  position: fixed;
  left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(40,40,40,0.92);
  color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 20px;
  z-index: 50; opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-color-scheme: dark) {
  .toast { background: rgba(120,120,128,0.95); }
}

/* ---------- 今日能量条 + 暖光 ---------- */
.sun-aura {
  position: fixed; top: 0; left: 0; right: 0; height: 240px;
  background: radial-gradient(120% 100% at 50% 0%, rgba(255, 196, 110, 0.55), rgba(255, 196, 110, 0) 70%);
  opacity: var(--energy, 0);
  transition: opacity 0.6s ease;
  pointer-events: none; z-index: 1;
}
.energy {
  max-width: 480px; margin: 14px auto 2px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px; font-size: 13px; color: var(--text-2);
}
.energy-label { font-weight: 600; white-space: nowrap; }
.energy-track {
  flex: 1; height: 9px; border-radius: 999px;
  background: var(--card); overflow: hidden; box-shadow: inset 0 0 0 0.5px var(--separator);
}
.energy-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #ffd45e, var(--accent));
  border-radius: 999px; transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.energy-pct { font-weight: 700; color: var(--accent); min-width: 34px; text-align: right; }
body.full-energy .sun-aura { opacity: 0.95; }

/* Streak 连击徽章 */
.streak {
  font-size: 13px; font-weight: 700; color: #ff7a3d;
  background: rgba(255, 122, 61, 0.14); padding: 1px 7px; border-radius: 8px;
}

/* 专注按钮 */
.focus-btn {
  flex: 0 0 auto; margin-left: 10px;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; transition: transform 0.12s;
}
.focus-btn:active { transform: scale(0.9); }

/* 撒花 */
.confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* 番茄专注弹层 */
.focus-modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(30, 20, 10, 0.55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s;
}
.focus-modal.show { opacity: 1; }
/* 关键修复：hidden 属性必须真正隐藏遮罩，否则它会铺满全屏并吞掉所有点击 */
.focus-modal[hidden] { display: none; }
.focus-card {
  background: var(--card); border-radius: var(--radius-lg);
  padding: 30px 28px 24px; width: 280px; text-align: center;
  box-shadow: var(--shadow); transform: scale(0.9); transition: transform 0.3s;
}
.focus-modal.show .focus-card { transform: scale(1); }
.focus-ring { position: relative; width: 160px; height: 160px; margin: 0 auto 16px; }
.focus-ring svg { width: 160px; height: 160px; transform: rotate(-90deg); }
.focus-bg { fill: none; stroke: var(--card-2); stroke-width: 9; }
.focus-prog { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.focus-time {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums;
}
.focus-title { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 4px; word-break: break-word; }
.focus-hint { font-size: 13px; color: var(--text-2); margin-bottom: 18px; }
.focus-stop {
  border: none; background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 600; padding: 11px 0; width: 100%;
  border-radius: 12px; cursor: pointer;
}
.focus-stop:active { opacity: 0.85; }
