/* ============================================================
   待办 · App 化样式
   目标：封装成 APK 后与原生应用无差别
   - 严格的 8pt 栅格与 44px 最小触控区
   - 安全区（刘海/手势条）适配
   - 无 hover 依赖（触摸设备没有 hover）
   - 系统级过渡动画（60fps，transform/opacity only）
   ============================================================ */

:root {
  /* 亮色 */
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-input: #eef0f4;
  --bg-press: #e4e7ec;
  --text: #14161c;
  --text-2: #5c6370;
  --text-3: #9aa1ad;
  --line: #e8eaee;
  --accent: #4f7cff;
  --accent-weak: #ebf1ff;
  --danger: #f0453f;
  --warn: #f59e0b;
  --ok: #22c55e;

  --p1: #3b82f6;
  --p3: #f59e0b;
  --p5: #f0453f;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 56px;

  --dur: 220ms;
  --ease: cubic-bezier(.32, .72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1017;
    --bg-card: #171b23;
    --bg-input: #1f242e;
    --bg-press: #2a303c;
    --text: #eef0f4;
    --text-2: #98a0ad;
    --text-3: #636b78;
    --line: #242a34;
    --accent: #5b8cff;
    --accent-weak: #1b2337;
    --danger: #ff5a54;
  }
}

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  /* App 里不该出现文本选中，只有输入框需要 */
  user-select: none;
  -webkit-user-select: none;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

.hidden { display: none !important; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--bg-input);
  border: 0;
  border-radius: var(--r-sm);
  padding: 12px 14px;
  outline: none;
  width: 100%;
  transition: background var(--dur) var(--ease);
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

input:focus, textarea:focus { background: var(--bg-press); }

textarea { resize: none; }

/* iOS 输入框字体小于 16px 会触发自动放大，App 里必须避免 */
input, textarea, select { font-size: 16px; }

/* ══════════════════════ 通用按钮 ══════════════════════ */

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  padding: 14px 20px;
  border-radius: var(--r-md);
  transition: opacity var(--dur) var(--ease), transform 120ms;
}
.btn-primary:active { opacity: .82; transform: scale(.985); }
.btn-primary:disabled { opacity: .45; }

.btn-block { display: block; width: 100%; }

.btn-outline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text-2);
  font-size: 15px;
  padding: 13px;
  border-radius: var(--r-md);
  transition: background var(--dur);
}
.btn-outline:active { background: var(--bg-press); }
.btn-outline svg { width: 17px; height: 17px; }

.btn-text {
  color: var(--text-2);
  font-size: 15px;
  padding: 10px 4px;
}
.btn-text:active { opacity: .6; }

.btn-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-2);
  transition: background 140ms;
  flex: 0 0 auto;
}
.btn-icon:active { background: var(--bg-press); }
.btn-icon svg { width: 21px; height: 21px; }

.btn-mini {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-weak);
}
.btn-mini:active { opacity: .7; }
.btn-mini svg { width: 16px; height: 16px; }

.btn-mini-text {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 4px;
}

/* ══════════════════════ 登录 ══════════════════════ */

.login-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 28px calc(40px + var(--safe-b));
  background: var(--bg);
  z-index: 200;
}

.login-hero {
  text-align: center;
  margin-bottom: 40px;
}

.app-icon-lg {
  width: 76px;
  height: 76px;
  margin: 0 auto 20px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #6b96ff, #3358db);
  box-shadow: 0 10px 28px rgba(79, 124, 255, .34);
}
.app-icon-lg svg { width: 38px; height: 38px; }

.login-hero h1 {
  margin: 0 0 6px;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.4px;
}

.login-sub {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-3);
}

.login-form { display: flex; flex-direction: column; gap: 12px; }

.field input {
  padding: 15px 16px;
  border-radius: var(--r-md);
  text-align: center;
  font-size: 16px;
}

.login-form .btn-primary { margin-top: 8px; }

.login-err {
  min-height: 20px;
  text-align: center;
  font-size: 13.5px;
  color: var(--danger);
}

/* ══════════════════════ 主体布局 ══════════════════════ */

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ─────── 顶栏 ─────── */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: var(--bg);
  position: relative;
  z-index: 10;
}

.topbar-left {
  min-width: 0;
  flex: 1 1 auto;
  padding-bottom: 2px;
}

#view-title {
  margin: 0;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.6px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-sub {
  display: block;
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 1px;
  height: 16px;
}

.topbar-right {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
  padding-bottom: 4px;
}

/* ─────── 搜索条 ─────── */

.search-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 16px 8px;
  padding: 0 4px 0 12px;
  background: var(--bg-input);
  border-radius: var(--r-md);
  height: 44px;
  animation: dropIn 200ms var(--ease);
}

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

.search-ico { width: 17px; height: 17px; color: var(--text-3); flex: 0 0 auto; }

.search-bar input {
  background: none;
  padding: 0;
  flex: 1 1 auto;
  font-size: 16px;
}
.search-bar input:focus { background: none; }

/* ─────── 滚动区 ─────── */

.screen {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  /* 底部留足空间：标签栏高度 + 安全区 + 最后一张卡片到边缘的呼吸感。
     留少了会让最后一条任务被标签栏压住。 */
  padding: 0 0 calc(var(--tabbar-h) + var(--safe-b) + 28px);
  position: relative;
}

/* 下拉刷新指示器 */
.ptr {
  height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text-3);
  transition: height 200ms var(--ease);
}
.ptr svg { width: 20px; height: 20px; }
.ptr.active { height: 44px; }
.ptr.spin svg { animation: spin 800ms linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ─────── 快速添加 ─────── */

.quick-add {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 16px 10px;
  padding: 4px 6px 4px 4px;
  background: var(--bg-card);
  border-radius: var(--r-md);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
  min-height: 48px;
}

.qa-plus {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-weak);
  color: var(--accent);
  transition: transform 160ms var(--ease);
}
.qa-plus:active { transform: scale(.9); }
.qa-plus svg { width: 20px; height: 20px; }

.quick-add input {
  flex: 1 1 auto;
  background: none;
  padding: 0;
  font-size: 15.5px;
  min-width: 0;
}
.quick-add input:focus { background: none; }

.qa-send {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}
.qa-send svg { width: 17px; height: 17px; }

.qa-preview {
  margin: -4px 16px 10px;
  padding: 0 4px;
  font-size: 12.5px;
  color: var(--text-2);
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.qa-preview.show { display: flex; }

.qa-preview .chip {
  background: var(--accent-weak);
  color: var(--accent);
  padding: 3px 9px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 12px;
}

/* ─────── 任务列表 ─────── */

.task-groups { padding: 0 12px; }

.group { margin-bottom: 6px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 6px 8px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-3);
  letter-spacing: .3px;
  text-transform: uppercase;
}
.group-head .count {
  font-weight: 500;
  color: var(--text-3);
  opacity: .8;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 12px;
  margin-bottom: 2px;
  background: var(--bg-card);
  border-radius: var(--r-md);
  position: relative;
  transition: background 140ms, transform 160ms var(--ease);
  overflow: hidden;
}

.task-item:active { background: var(--bg-press); }

.task-item.done .task-title {
  text-decoration: line-through;
  color: var(--text-3);
}

/* 勾选圈：36px 触控热区包着 22px 视觉圆 */
.check {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--text-3);
  display: grid;
  place-items: center;
  transition: all 160ms var(--ease);
  position: relative;
}
/* 扩大触控热区 */
.check::before {
  content: '';
  position: absolute;
  inset: -8px;
}

.check svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  transform: scale(.5);
  transition: all 160ms var(--ease);
  color: #fff;
}

.task-item.done .check {
  background: var(--accent);
  border-color: var(--accent);
}
.task-item.done .check svg { opacity: 1; transform: scale(1); }

.task-body { flex: 1 1 auto; min-width: 0; }

.task-title {
  font-size: 15.5px;
  line-height: 1.42;
  word-break: break-word;
  transition: color 160ms;
}

.task-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--text-2);
}

.task-sub .due {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.task-sub .due svg { width: 12px; height: 12px; }
.task-sub .due.overdue { color: var(--danger); font-weight: 600; }
.task-sub .due.today { color: var(--warn); }

.task-sub .tag {
  background: var(--bg-input);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  color: var(--text-2);
}

.task-sub .subtask-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-3);
}
.task-sub .subtask-count svg { width: 12px; height: 12px; }

.task-sub .repeat-icon svg { width: 12px; height: 12px; }

/* 优先级：左侧竖色条，比圆点更克制也更好认 */
.task-item[data-p="1"]::before,
.task-item[data-p="3"]::before,
.task-item[data-p="5"]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
}
.task-item[data-p="1"]::before { background: var(--p1); }
.task-item[data-p="3"]::before { background: var(--p3); }
.task-item[data-p="5"]::before { background: var(--p5); }

/* 左滑删除层 */
.swipe-del {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 84px;
  background: var(--danger);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--r-md);
}

/* ─────── 空状态 ─────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 32px;
  text-align: center;
}

.empty-art {
  width: 84px;
  height: 84px;
  margin-bottom: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-card);
  color: var(--text-3);
  opacity: .8;
}
.empty-art svg { width: 38px; height: 38px; }

.empty-text {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
}

.empty-hint {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.6;
  max-width: 260px;
}

/* ══════════════════════ 底部标签栏 ══════════════════════ */

.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  align-items: stretch;
  /* 用不透明背景 + 细微上边框，而不是 backdrop-filter 半透明。
     半透明会让滚动的任务文字透过标签栏，视觉上很脏；
     原生 App 的标签栏也是实色为主。 */
  background: var(--bg);
  border-top: 1px solid var(--line);
  z-index: 30;
}

/* 标签栏上方渐隐遮罩，让滚动内容自然淡出，而不是硬切 */
.tabbar::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 20px;
  background: linear-gradient(to top, var(--bg) 20%, transparent);
  pointer-events: none;
}

.tab {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-3);
  position: relative;
  transition: color 160ms;
  min-width: 0;
}

.tab.active { color: var(--accent); }

.tab-ico {
  display: grid;
  place-items: center;
  width: 26px;
  height: 24px;
  position: relative;
}
.tab-ico svg { width: 23px; height: 23px; }

.tab-label {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .1px;
}

.tab-badge {
  position: absolute;
  top: 4px;
  left: 50%;
  margin-left: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.tab-badge.show { display: flex; }

/* 中间悬浮大加号 */
.tab-fab { flex: 0 0 68px; }

.fab-inner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #6b96ff, #3a62e0);
  color: #fff;
  box-shadow: 0 5px 16px rgba(79, 124, 255, .4);
  transition: transform 180ms var(--ease);
}
.tab-fab:active .fab-inner { transform: scale(.9); }
.fab-inner svg { width: 24px; height: 24px; }

/* ══════════════════════ 全屏 Sheet ══════════════════════ */

.sheet {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: sheetIn 260ms var(--ease);
}

@keyframes sheetIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(var(--safe-t) + 6px) 10px 6px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}

.sheet-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1 1 auto;
  text-align: center;
}

.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 4px 16px 24px;
}

.sheet-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.save-hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-3);
}

/* ─────── 详情：标题区 ─────── */

.d-title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0 14px;
}

.check-big {
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  margin-top: 3px;
  border-radius: 50%;
  border: 2px solid var(--text-3);
  display: grid;
  place-items: center;
  color: transparent;
  transition: all 160ms var(--ease);
}
.check-big svg { width: 15px; height: 15px; }
.check-big[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.d-title {
  flex: 1 1 auto;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
  background: none;
  padding: 0;
  min-height: 30px;
  max-height: 200px;
  overflow: hidden;
  letter-spacing: -.2px;
}
.d-title:focus { background: none; }

/* ─────── 详情：快捷 chip ─────── */

.d-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  border-radius: 11px;
  background: var(--bg-card);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all 140ms;
  max-width: 100%;
}
.chip:active { background: var(--bg-press); }
.chip svg { width: 14px; height: 14px; flex: 0 0 auto; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip.on {
  background: var(--accent-weak);
  color: var(--accent);
}

/* ─────── 详情：展开面板 ─────── */

.d-panel {
  margin-top: 10px;
  padding: 4px 14px 8px;
  background: var(--bg-card);
  border-radius: var(--r-md);
  animation: panelIn 200ms var(--ease);
}

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

.panel-title {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-3);
  letter-spacing: .4px;
  text-transform: uppercase;
  padding: 12px 0 6px;
}

.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  min-height: 46px;
}
.panel-title + .panel-row { border-top: 0; }

.panel-row > label {
  font-size: 14.5px;
  color: var(--text-2);
  flex: 0 0 auto;
}

.panel-row input[type=date],
.panel-row input[type=time] {
  width: auto;
  min-width: 130px;
  background: var(--bg-input);
  padding: 9px 11px;
  font-size: 14.5px;
  text-align: right;
}

.panel-row select {
  width: auto;
  min-width: 128px;
  background: var(--bg-input);
  padding: 9px 11px;
  font-size: 14.5px;
  text-align: right;
}

/* 开关 */
.switch {
  width: 48px;
  height: 29px;
  border-radius: 15px;
  background: var(--bg-press);
  position: relative;
  transition: background 200ms var(--ease);
  flex: 0 0 auto;
}
.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform 200ms var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] span { transform: translateX(19px); }

/* 优先级选项 */
.prio-list, .repeat-list { display: flex; flex-direction: column; }

.prio-opt, .repeat-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 4px;
  border-top: 1px solid var(--line);
  font-size: 14.5px;
  color: var(--text);
  text-align: left;
  width: 100%;
}
.prio-opt:first-child, .repeat-opt:first-child { border-top: 0; }
.prio-opt:active, .repeat-opt:active { opacity: .6; }

.prio-opt .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-3);
  flex: 0 0 auto;
}
.prio-opt .dot.p1 { background: var(--p1); }
.prio-opt .dot.p3 { background: var(--p3); }
.prio-opt .dot.p5 { background: var(--p5); }

.prio-opt.active, .repeat-opt.active {
  color: var(--accent);
  font-weight: 600;
}
.prio-opt.active::after, .repeat-opt.active::after {
  content: '';
  margin-left: auto;
  width: 15px;
  height: 8px;
  border: solid var(--accent);
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg);
}

/* 清单选择 */
.project-list { display: flex; flex-direction: column; }

.project-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 4px;
  border-top: 1px solid var(--line);
  font-size: 14.5px;
  width: 100%;
  text-align: left;
}
.project-opt:first-child { border-top: 0; }
.project-opt:active { opacity: .6; }
.project-opt .pdot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}
.project-opt.active { color: var(--accent); font-weight: 600; }
.project-opt.active::after {
  content: '';
  margin-left: auto;
  width: 15px;
  height: 8px;
  border: solid var(--accent);
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg);
}

/* ─────── 详情：区块 ─────── */

.d-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.d-section:last-of-type { border-bottom: 0; }

.d-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-3);
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.sub-progress {
  font-weight: 500;
  color: var(--text-3);
  text-transform: none;
  letter-spacing: 0;
}

/* 标签 */
.tag-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
}
.tag-wrap:empty { margin-bottom: 0; }

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-weak);
  color: var(--accent);
  padding: 5px 9px 5px 11px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 500;
}
.tag-pill button {
  opacity: .55;
  font-size: 15px;
  line-height: 1;
  padding: 0 1px;
}
.tag-pill button:active { opacity: 1; }

.tag-input {
  background: transparent;
  padding: 6px 0;
  font-size: 14.5px;
  color: var(--text-2);
}
.tag-input:focus { background: transparent; }

/* 子任务 */
.subtask-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 6px;
}

.subtask {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-radius: 8px;
  transition: background 140ms;
}
.subtask:active { background: var(--bg-card); }

.subtask .s-check {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--text-3);
  display: grid;
  place-items: center;
  color: transparent;
  transition: all 160ms var(--ease);
}
.subtask .s-check svg { width: 12px; height: 12px; }
.subtask.done .s-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.subtask .s-text {
  flex: 1 1 auto;
  font-size: 14.5px;
  word-break: break-word;
}
.subtask.done .s-text {
  text-decoration: line-through;
  color: var(--text-3);
}

.subtask .s-del {
  color: var(--text-3);
  font-size: 17px;
  padding: 4px 8px;
  line-height: 1;
  flex: 0 0 auto;
}

.subtask-add {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 4px;
  color: var(--text-3);
}
.subtask-add svg { width: 17px; height: 17px; flex: 0 0 auto; }
.subtask-add input {
  background: transparent;
  padding: 4px 0;
  font-size: 14.5px;
}
.subtask-add input:focus { background: transparent; }

/* 备注 */
.d-content {
  background: var(--bg-card);
  border-radius: var(--r-md);
  padding: 13px 14px;
  font-size: 14.5px;
  line-height: 1.65;
  min-height: 92px;
}

.d-meta {
  padding: 16px 0 0;
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.9;
}

.d-foot-space { height: 24px; }

/* ══════════════════════ 抽屉 ══════════════════════ */

.drawer {
  position: absolute;
  inset: 0;
  z-index: 60;
}

.drawer-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .42);
  animation: fadeIn 200ms;
}

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

.drawer-panel {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 82%;
  max-width: 320px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: drawerIn 260ms var(--ease);
  box-shadow: 4px 0 24px rgba(0, 0, 0, .16);
}

@keyframes drawerIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--safe-t) + 20px) 20px 18px;
}

.drawer-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #6b96ff, #3358db);
  color: #fff;
}
.drawer-avatar svg { width: 23px; height: 23px; }

.drawer-name {
  font-size: 16px;
  font-weight: 650;
}

.drawer-sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 1px;
}

.drawer-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 10px 16px;
}

.drawer-group { margin-bottom: 20px; }

.drawer-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-3);
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.d-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--r-sm);
  font-size: 15px;
  color: var(--text);
  transition: background 140ms;
}
.d-item:active { background: var(--bg-press); }

.d-item.active {
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 600;
}

.d-item .d-ico {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--text-2);
}
.d-item .d-ico svg { width: 19px; height: 19px; }
.d-item.active .d-ico { color: var(--accent); }

.d-item .d-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.d-item .d-count {
  font-size: 12.5px;
  color: var(--text-3);
  font-weight: 500;
}
.d-item.active .d-count { color: var(--accent); }

.d-item .d-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.drawer-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
}

.drawer-foot-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px;
  border-radius: var(--r-sm);
  background: var(--bg-card);
  font-size: 13.5px;
  color: var(--text-2);
}
.drawer-foot-btn:active { background: var(--bg-press); }
.drawer-foot-btn svg { width: 15px; height: 15px; }

/* ══════════════════════ 设置页 ══════════════════════ */

.set-section { margin-bottom: 28px; }

.set-section-title {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-3);
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.set-hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.65;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  background: var(--bg-card);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  font-size: 14.5px;
}

.set-val { color: var(--text-3); font-size: 13.5px; }

.channel-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

.channel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--r-sm);
  font-size: 14px;
}
.channel-row .c-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-row .c-del {
  color: var(--text-3);
  font-size: 13px;
  padding: 5px 8px;
}
.channel-row .c-del:active { color: var(--danger); }

/* ══════════════════════ 弹窗 ══════════════════════ */

.modal {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .45);
  animation: fadeIn 180ms;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: var(--r-lg);
  overflow: hidden;
  animation: modalIn 240ms var(--ease);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.94) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  font-size: 16px;
  font-weight: 650;
}

.modal-body { padding: 8px 16px 16px; }

.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  margin: 12px 0 6px;
}

.modal-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.55;
}

.modal-result {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-all;
}

.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px 16px;
}

.modal-foot .btn-primary { padding: 10px 20px; font-size: 15px; }

/* ══════════════════════ 操作菜单 ══════════════════════ */

.action-sheet {
  position: absolute;
  inset: 0;
  z-index: 90;
}

.action-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .42);
  animation: fadeIn 180ms;
}

.action-panel {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(8px + var(--safe-b));
  background: var(--bg-card);
  border-radius: var(--r-lg);
  overflow: hidden;
  animation: actionIn 240ms var(--ease);
  padding-bottom: 6px;
}

@keyframes actionIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.action-title {
  padding: 14px 20px 10px;
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 15px 20px;
  font-size: 15.5px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.action-item:active { background: var(--bg-press); }
.action-item.danger { color: var(--danger); }
.action-item svg { width: 19px; height: 19px; flex: 0 0 auto; }

.action-cancel {
  width: 100%;
  padding: 15px;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-top: 6px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.action-cancel:active { background: var(--bg-press); }

/* ══════════════════════ Toast ══════════════════════ */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px);
  transform: translate(-50%, 10px);
  background: rgba(20, 22, 28, .94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
  opacity: 0;
  transition: opacity 200ms, transform 200ms var(--ease);
  z-index: 100;
  pointer-events: none;
  max-width: 84%;
  text-align: center;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  .toast { background: rgba(238, 240, 244, .95); color: #14161c; }
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ══════════════════════ 大屏适配 ══════════════════════ */
/* 平板/桌面：内容居中，最大宽度限制，避免拉伸变形 */

@media (min-width: 620px) {
  .screen { padding-left: max(0px, calc((100vw - 620px) / 2)); padding-right: max(0px, calc((100vw - 620px) / 2)); }
  .topbar { padding-left: max(16px, calc((100vw - 620px) / 2 + 16px)); padding-right: max(16px, calc((100vw - 620px) / 2 + 16px)); }
  .quick-add { margin-left: max(16px, calc((100vw - 620px) / 2 + 16px)); margin-right: max(16px, calc((100vw - 620px) / 2 + 16px)); }
  .sheet-body { padding-left: max(16px, calc((100vw - 620px) / 2 + 16px)); padding-right: max(16px, calc((100vw - 620px) / 2 + 16px)); }
  .tabbar { padding-left: calc((100vw - 620px) / 2); padding-right: calc((100vw - 620px) / 2); }
  .drawer-panel { width: 320px; }
  .task-groups { padding-left: max(0px, calc((100vw - 620px) / 2)); padding-right: max(0px, calc((100vw - 620px) / 2)); }
}

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