/* 任务笔记 · 视觉样式
 * 白底、细线、低饱和；卡片直接操作属性，笔记就地自动保存。
 * 笔记字号按选区标记，未标记的文字为默认大小。
 */

/* ---------------- 字号档位 ---------------- */

:root {
  --fs-base: 15px;
  --fs-sm: 13.5px;
  --fs-xs: 12.5px;
  --fs-title: 15.5px;
  --fs-note: 15px;
  --fs-h1: 22px;
  --fs-chip: 12px;
  --fs-menu: 14px;
}

/* 笔记字号按选区标记在 [data-size] 上，未标记的为默认大小 */
.note-editor [data-size="0"] { font-size: 13px; }
.note-editor [data-size="1"] { font-size: 15px; }
.note-editor [data-size="2"] { font-size: 17.5px; }
.note-editor [data-size="3"] { font-size: 20px; }

/* ---------------- 颜色变量 ---------------- */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei",
          "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;

  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-hover: #f1f3f6;
  --border: #e7e9ee;
  --border-strong: #d8dce3;

  --text: #1c2128;
  --text-2: #5a6472;
  --text-3: #8b95a3;

  --accent: #2f6feb;
  --accent-soft: rgba(47, 111, 235, 0.14);
  --danger: #e5484d;

  --shadow: 0 12px 32px rgba(20, 25, 35, 0.12);
}

html[data-theme="dark"] {
  --bg: #15171c;
  --bg-soft: #1b1e24;
  --bg-hover: #232830;
  --border: #2a2f38;
  --border-strong: #3a404b;

  --text: #e8eaed;
  --text-2: #a8b0bb;
  --text-3: #7d8794;

  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.18);
  --danger: #f2555a;

  --shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}

/* 护眼绿：低饱和豆绿底，避免纯白刺眼 */
html[data-theme="green"] {
  --bg: #edf5ed;
  --bg-soft: #e4efe4;
  --bg-hover: #dbe9db;
  --border: #d4e4d4;
  --border-strong: #bcd3bc;

  --text: #1d2b20;
  --text-2: #4b6150;
  --text-3: #778b7a;

  --accent: #2f7d4f;
  --accent-soft: rgba(47, 125, 79, 0.14);
  --danger: #c43f45;

  --shadow: 0 12px 32px rgba(30, 50, 35, 0.12);
}

/* 暖黄：米色纸感 */
html[data-theme="warm"] {
  --bg: #fbf5e9;
  --bg-soft: #f6eddc;
  --bg-hover: #efe3cf;
  --border: #e8dac2;
  --border-strong: #d8c5a6;

  --text: #33291c;
  --text-2: #6b5a44;
  --text-3: #9a866c;

  --accent: #b06a2c;
  --accent-soft: rgba(176, 106, 44, 0.14);
  --danger: #c0443f;

  --shadow: 0 12px 32px rgba(60, 45, 25, 0.12);
}

/* 雾蓝：淡蓝灰 */
html[data-theme="blue"] {
  --bg: #edf3f9;
  --bg-soft: #e4edf6;
  --bg-hover: #dae6f2;
  --border: #d4e1ed;
  --border-strong: #bacfe2;

  --text: #1c2a38;
  --text-2: #4d6076;
  --text-3: #7b8da3;

  --accent: #2f6feb;
  --accent-soft: rgba(47, 111, 235, 0.14);
  --danger: #d23f44;

  --shadow: 0 12px 32px rgba(30, 50, 80, 0.12);
}

/* ---------------- 基础 ---------------- */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font-family: inherit; }

button { -webkit-tap-highlight-color: transparent; }

::selection { background: var(--accent-soft); }

mark {
  background: #fde68a;
  color: inherit;
  padding: 0 1px;
  border-radius: 3px;
}
html[data-theme="dark"] mark {
  background: #7a5b00;
  color: #fff7db;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: transparent;
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}
*:hover::-webkit-scrollbar-thumb { background: var(--border-strong); background-clip: content-box; }

/* ---------------- 骨架 ---------------- */

.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  flex: 0 0 auto;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: relative;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }

.brand-mark {
  width: 25px;
  height: 25px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
}
.brand-mark .ic { width: 14px; height: 14px; stroke-width: 2.6; }

.brand-name { font-size: var(--fs-base); font-weight: 600; letter-spacing: 0.01em; }

.brand-tag {
  font-size: var(--fs-xs);
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 5px;
  line-height: 18px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 440px;
  height: 36px;
  padding: 0 10px;
  margin-left: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.search:focus-within {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-icon { color: var(--text-3); width: 15px; height: 15px; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--text);
}
.search input::placeholder { color: var(--text-3); }

.search-kbd {
  font-family: var(--font);
  font-size: var(--fs-xs);
  line-height: 18px;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 4px;
  background: var(--bg);
}

.search-clear {
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: calc(var(--fs-sm) + 3px);
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 4px;
}
.search-clear:hover { color: var(--text); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.segment {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.segment button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.segment button:hover { color: var(--text); }
.segment button.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}
html[data-theme="dark"] .segment button.active { background: var(--bg-hover); }

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ---------------- 顶栏：笔记文字工具 ---------------- */

.topbar-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 整体底色切换 */
.theme-switch { position: relative; flex: 0 0 auto; }
.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-2);
  font-size: var(--fs-xs);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.theme-btn:hover { border-color: var(--border-strong); color: var(--text); }
.theme-dot {
  width: 13px;
  height: 13px;
  flex: none;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: #fff;
}
.theme-label { line-height: 1; }
.theme-chevron { width: 12px; height: 12px; color: var(--text-3); }
.theme-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 70;
  width: 164px;
  padding: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}
.theme-option:hover { background: var(--bg-hover); color: var(--text); }
.theme-option.active { background: var(--accent-soft); color: var(--text); }
.theme-option-dot {
  width: 14px;
  height: 14px;
  flex: none;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--swatch);
}
.theme-option-name { flex: 1; }
.theme-option .ic { width: 14px; height: 14px; color: var(--accent); }

.nt-colors {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: opacity 0.15s;
}
.nt-colors.is-disabled { opacity: 0.35; }

.nt-color {
  width: 14px;
  height: 14px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
  transition: transform 0.1s;
}
.nt-color:hover { transform: scale(1.2); }
.nt-colors.is-disabled .nt-color { cursor: default; }
.nt-colors.is-disabled .nt-color:hover { transform: none; }

.nt-clear {
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text-3);
  font-size: var(--fs-xs);
  cursor: pointer;
}
.nt-clear:hover { color: var(--text); border-color: var(--border-strong); }
.nt-colors.is-disabled .nt-clear { cursor: default; color: var(--text-3); }

.tb-sep {
  width: 1px;
  height: 16px;
  background: var(--border-strong);
  opacity: 0.6;
}

.nt-sizes {
  display: inline-flex;
  gap: 1px;
  padding: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 7px;
  transition: opacity 0.15s;
}
.nt-sizes.is-disabled { opacity: 0.35; }
.nt-sizes button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-xs);
  padding: 2px 7px;
  border-radius: 5px;
  cursor: pointer;
}
.nt-sizes.is-disabled button { cursor: default; }
.nt-sizes button:hover { color: var(--text); }
.nt-sizes button.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
}
html[data-theme="dark"] .nt-sizes button.active { background: var(--bg-hover); }

.menu-wrap { position: relative; }

.menu {
  position: absolute;
  top: 38px;
  right: 0;
  width: 240px;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 30;
}
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-menu);
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--bg-hover); }
.menu-item .ic { color: var(--text-3); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 6px; }

.menu-note {
  padding: 8px 9px 4px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  border-top: 1px solid var(--border);
  margin-top: 5px;
}

/* ---------------- 侧栏 ---------------- */

.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 12px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
}

.side-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  letter-spacing: 0.06em;
  padding: 10px 9px 4px;
}

.mode-list { display: flex; flex-direction: column; gap: 2px; }

.mode-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.mode-item:hover { background: var(--bg-hover); color: var(--text); }
.mode-item.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--border);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--c, var(--text-3));
}
.dot-all {
  background: transparent;
  border: 1.5px solid var(--text-3);
  width: 9px;
  height: 9px;
}

.hash {
  width: 9px;
  flex: 0 0 auto;
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-3);
  line-height: 1;
}
.tag-item.active .hash { color: var(--accent); }

.mode-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.count {
  margin-left: auto;
  font-size: var(--fs-xs);
  line-height: 19px;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 6px;
  min-width: 24px;
  text-align: center;
}
.mode-item.active .count { color: var(--text-2); }

.side-add,
.side-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}
.side-add:hover,
.side-link:hover { background: var(--bg-hover); color: var(--text-2); }
.side-add { margin-top: 2px; }
.side-add .ic { width: 14px; height: 14px; }

.side-foot {
  margin-top: auto;
  padding: 14px 9px 2px;
  font-size: var(--fs-xs);
  line-height: 1.5;
  color: var(--text-3);
}
.save-state.error { color: var(--danger); }

/* ---------------- 主区域 ---------------- */

.main { overflow-y: auto; overflow-x: hidden; min-height: 0; padding: 26px 32px 110px; }

.main-inner { max-width: 880px; margin: 0 auto; }

.main-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.main-head h1 {
  margin: 0;
  font-size: var(--fs-h1);
  font-weight: 650;
  letter-spacing: -0.01em;
}
.view-sub { font-size: var(--fs-xs); color: var(--text-3); }

.quick-add {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 18px;
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: 11px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.quick-add:focus-within {
  border-style: solid;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.qa-icon { color: var(--text-3); }
.quick-add > input {
  flex: 1;
  min-width: 0;
  padding-right: 258px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-base);
  color: var(--text);
}
.quick-add > input::placeholder { color: var(--text-3); }

/* 悬浮在输入框右侧的快捷属性 */
.qa-tools {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 16px;
  background: linear-gradient(90deg, transparent 0, var(--bg) 16px);
}

.qa-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 25px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: var(--fs-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.qa-tool:hover { border-color: var(--border-strong); color: var(--text); }
.qa-tool.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.qa-tool .ic { width: 12px; height: 12px; color: var(--text-3); }
.qa-tool .dot { width: 7px; height: 7px; }
.qa-tool-label { line-height: 1; }

.qa-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 10px;
  z-index: 40;
  width: min(340px, calc(100% - 20px));
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.qa-panel .editor-head { margin-bottom: 7px; }
.qa-panel .editor-row input[type="date"] { flex: 1 1 100%; }
.qa-panel .editor-options { max-height: 190px; overflow-y: auto; }
.qa-panel .editor-add { margin-top: 9px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list:has(.task-item.expanded) { padding-bottom: 42vh; }

/* ---------------- 登录 ---------------- */

.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg-soft);
}
.login-card {
  width: min(380px, 100%);
  padding: 28px 26px 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: var(--fs-title);
  margin-bottom: 22px;
}
.login-brand .brand-mark { width: 26px; height: 26px; font-size: 15px; }
.login-card h1 { font-size: 20px; margin: 0 0 8px; }
.login-hint { color: var(--text-3); font-size: var(--fs-sm); line-height: 1.7; margin: 0 0 18px; }
.login-pin { margin-bottom: 10px; font-size: 20px; letter-spacing: 0.2em; text-align: center; }
.login-submit { width: 100%; height: 38px; }
.login-error { min-height: 1.4em; margin: 10px 0 0; color: var(--danger); font-size: var(--fs-sm); }

/* ---------------- 任务卡片 ---------------- */

.task-item { position: relative; }

.task-card {
  position: relative;
  display: grid;
  grid-template-columns: 14px 20px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 13px 12px 13px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.task-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  bottom: 11px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--pcolor, var(--border-strong));
}
.task-card:hover { border-color: var(--border-strong); box-shadow: 0 2px 10px rgba(20, 25, 35, 0.05); }
html[data-theme="dark"] .task-card:hover { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35); }
.task-card.done { background: var(--bg-soft); }
.task-card.done .card-title { color: var(--text-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.task-card.dragging { opacity: 0.4; }

.task-item.expanded .task-card {
  border-color: var(--accent);
  border-bottom-color: transparent;
  border-radius: 12px 12px 0 0;
  box-shadow: none;
}
.task-item.expanded {
  border-radius: 12px;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.grip {
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-3);
  opacity: 0.35;
  cursor: default;
  line-height: 0;
}
.task-card.draggable .grip { cursor: grab; }
.task-card.draggable:hover .grip { opacity: 0.75; }
.grip .ic { width: 14px; height: 14px; }

.check {
  width: 19px;
  height: 19px;
  margin-top: 1px;
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: transparent;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.check .ic { width: 11px; height: 11px; stroke-width: 2.6; }
.check:hover { border-color: var(--accent); }
.task-card.done .check { background: var(--accent); border-color: var(--accent); }

.card-body { min-width: 0; padding-top: 1px; }
.card-title {
  font-size: var(--fs-title);
  font-weight: 500;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.card-title-edit {
  width: 100%;
  padding: 1px 6px;
  margin-left: -6px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-title);
  font-weight: 500;
  line-height: 1.5;
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}
.card-meta-left,
.card-meta-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.card-meta-right { margin-left: auto; justify-content: flex-end; }
.card-meta .qa-tool { height: 24px; }
.card-meta .qa-tool.overdue { color: var(--danger); }
.card-meta .qa-tool.today { color: #b9700a; }
html[data-theme="dark"] .card-meta .qa-tool.today { color: #f5a524; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  font-size: var(--fs-chip);
  color: var(--text-2);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: nowrap;
}
.chip .ic { width: 12px; height: 12px; color: var(--text-3); }
.chip .dot { width: 6px; height: 6px; }

.chip-btn {
  font: inherit;
  font-size: var(--fs-chip);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.chip-btn:hover { border-color: var(--border-strong); color: var(--text); }

.chip-add {
  padding: 0 6px;
  color: var(--text-3);
  border-style: dashed;
  background: transparent;
}
.chip-add:hover { color: var(--text-2); }

.chip.overdue {
  color: #b3272d;
  background: #fdecec;
  border-color: #f6c9c9;
}
.chip.today {
  color: #9a5b00;
  background: #fff4e2;
  border-color: #f3d8ad;
}
.chip.none {
  color: var(--text-3);
  background: transparent;
  border-style: dashed;
}
.chip.none .ic { display: none; }
.chip.tag {
  background: transparent;
  border-color: transparent;
  color: var(--text-3);
  padding: 0 3px;
}
.chip.type-chip { background: var(--bg-soft); }

html[data-theme="dark"] .chip.overdue { color: #ff9a9a; background: #3a1d1f; border-color: #5a2a2d; }
html[data-theme="dark"] .chip.today { color: #ffc470; background: #3a2c17; border-color: #5a4326; }

.card-actions {
  align-self: start;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 520px;
  padding-top: 1px;
}
.card-actions .qa-tool {
  height: auto;
  min-height: 25px;
  padding: 3px 8px;
  white-space: normal;
  line-height: 1.35;
  text-align: left;
}
.card-actions .qa-tool .qa-tool-label { overflow-wrap: anywhere; }
.card-actions .icon-btn { width: 26px; height: 26px; }
.card-del:hover { color: var(--danger); }

.task-card.drop-before::after,
.task-card.drop-after::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.task-card.drop-before::after { top: -5px; }
.task-card.drop-after::after { bottom: -5px; }

/* ---------------- 卡片内联编辑 ---------------- */

.inline-editor {
  margin-top: 9px;
  padding: 9px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  animation: expand-in 0.12s ease-out;
}

.editor-head {
  font-size: var(--fs-xs);
  color: var(--text-3);
  letter-spacing: 0.04em;
  margin-bottom: 7px;
}

.editor-options { display: flex; flex-wrap: wrap; gap: 6px; }

.editor-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 29px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.editor-option:hover { border-color: var(--border-strong); color: var(--text); }
.editor-option.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.editor-option .ic { width: 12px; height: 12px; stroke-width: 2.4; color: var(--accent); }

.editor-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.editor-row input[type="date"] { flex: 0 0 160px; }
.recurrence-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; }
.recurrence-btn {
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-3);
  font-size: var(--fs-xs);
  cursor: pointer;
}
.recurrence-btn:hover { color: var(--text); border-color: var(--border-strong); }
.recurrence-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.editor-add { display: flex; gap: 6px; margin-top: 8px; }
.editor-add .control { flex: 1; }
.editor-empty { font-size: var(--fs-sm); color: var(--text-3); }

.control {
  width: 100%;
  height: 35px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.control-sm { height: 31px; font-size: var(--fs-sm); }
input[type="date"].control { cursor: text; }
html[data-theme="dark"] input[type="date"].control { color-scheme: dark; }

/* ---------------- 行内展开：笔记 + 附件 ---------------- */

.task-expand {
  background: var(--bg);
  border: 1px solid var(--accent);
  border-top: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  padding: 12px 16px 14px 68px;
  animation: expand-in 0.14s ease-out;
}

@keyframes expand-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}

.subtask-strip {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 7px 0 0 54px;
  cursor: default;
}
.subtask-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
  margin-bottom: 5px;
}
.subtask-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto 24px;
  align-items: center;
  gap: 7px;
  padding: 3px 2px;
  border-radius: 6px;
}
.subtask-item:hover { background: var(--bg-soft); }
.sub-check {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.sub-check .ic { width: 11px; height: 11px; }
.subtask-item.done .sub-check { background: var(--accent); border-color: var(--accent); }
.subtask-title {
  font-size: var(--fs-sm);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}
.subtask-item.done .subtask-title { color: var(--text-3); text-decoration: line-through; }
.subtask-title-edit {
  width: 100%;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-sm);
  outline: none;
}
.subtask-due-btn { height: 23px !important; }
.subtask-del { width: 24px; height: 24px; opacity: 0; transition: opacity 0.12s, color 0.12s; }
.subtask-item:hover .subtask-del,
.subtask-item:focus-within .subtask-del { opacity: 1; }
.subtask-del:hover { color: var(--danger); }
.subtask-due-panel {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 3px 27px;
}
.subtask-due-panel .control { width: 132px; }
.subtask-add-block { margin-top: 3px; }
.subtask-add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.subtask-new { flex: 0 0 auto; }
.subtask-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.task-item:not(.expanded) .subtask-actions { display: none; }
.subtask-input {
  flex: 1 1 220px;
  width: auto;
  max-width: 50%;
  min-width: 0;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-sm);
  outline: none;
}
.subtask-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.subtask-done-block {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.subtask-done-head {
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-bottom: 3px;
}

.note-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 9px;
}

.note-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.note-add:hover { color: var(--text-2); border-color: var(--text-3); background: var(--bg-soft); }
.note-add .ic { width: 13px; height: 13px; }

.note-list { display: flex; flex-direction: column; gap: 8px; }
.notes-empty {
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--text-3);
  padding: 2px 2px 4px;
}

.note-item {
  padding: 9px 11px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  transition: border-color 0.12s;
}
.note-item:hover,
.note-item:focus-within { border-color: var(--border); }

.note-collapsed {
  padding: 1px 2px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.note-collapsed:hover { color: var(--text); }
.note-toggle {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.note-toggle:hover { color: var(--text); background: var(--bg-hover); }
.note-toggle .ic { width: 12px; height: 12px; transform: rotate(90deg); }
.note-item.collapsed .note-toggle .ic { transform: rotate(0deg); }

.note-editor {
  min-height: 1.7em;
  max-height: 442px;
  padding: 1px 2px;
  font-size: var(--fs-note);
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  cursor: text;
  overflow-y: auto;
}
.note-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-3);
  pointer-events: none;
}
.note-editor:focus { cursor: text; }
.note-editor [data-note-date="1"] {
  color: var(--text);
  font-size: var(--fs-note);
  font-weight: 400;
}
.note-editor { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.note-editor::-webkit-scrollbar { width: 8px; }
.note-editor::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
.note-editor::-webkit-scrollbar-track { background: transparent; }

.note-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  opacity: 0.85;
  transition: opacity 0.12s;
}
.note-item:hover .note-bar,
.note-item:focus-within .note-bar { opacity: 1; }

.note-del {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: calc(var(--fs-xs) + 3px);
  line-height: 1;
  padding: 1px 5px;
  border-radius: 5px;
  cursor: pointer;
}
.note-del:hover { color: var(--danger); background: rgba(229, 72, 77, 0.1); }

/* 笔记内文字颜色（跟随主题取对比更好的色值） */
.note-editor [data-color="red"] { color: #d8353b; }
.note-editor [data-color="orange"] { color: #b9700a; }
.note-editor [data-color="green"] { color: #16803c; }
.note-editor [data-color="blue"] { color: #2258d6; }
.note-editor [data-color="purple"] { color: #7132c4; }
.note-editor [data-color="pink"] { color: #bf2c68; }

html[data-theme="dark"] .note-editor [data-color="red"] { color: #ff8f92; }
html[data-theme="dark"] .note-editor [data-color="orange"] { color: #ffc36b; }
html[data-theme="dark"] .note-editor [data-color="green"] { color: #74d99f; }
html[data-theme="dark"] .note-editor [data-color="blue"] { color: #8ab4ff; }
html[data-theme="dark"] .note-editor [data-color="purple"] { color: #c3a2ff; }
html[data-theme="dark"] .note-editor [data-color="pink"] { color: #ff9cc4; }

/* ---------------- 附件 ---------------- */

.attach-block {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.attach-list { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; }
.attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  border-radius: 6px;
}
.attach-item:hover { background: var(--bg-soft); }
.attach-open {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}
.attach-open .ic { color: var(--text-3); width: 14px; height: 14px; }
.attach-open:hover .attach-name { color: var(--accent); text-decoration: underline; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { font-size: var(--fs-xs); color: var(--text-3); }
.attach-del { width: 22px; height: 22px; opacity: 0; transition: opacity 0.12s; }
.attach-item:hover .attach-del { opacity: 1; }
.attach-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 29px;
  padding: 0 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.attach-add:hover { color: var(--text-2); border-color: var(--text-3); }
.attach-add .ic { width: 13px; height: 13px; }

/* ---------------- 已完成折叠区 ---------------- */

.done-block {
  margin-top: 26px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.done-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 5px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.done-toggle:hover { background: var(--bg-hover); color: var(--text); }

.done-toggle .chevron {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  transition: transform 0.15s;
}
.done-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }

.done-count {
  font-size: var(--fs-xs);
  line-height: 17px;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 6px;
}

.done-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  animation: expand-in 0.14s ease-out;
}

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 31px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--bg-hover); }
.btn-sm { height: 29px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.05); }
.btn-danger-ghost { color: var(--danger); background: transparent; border-color: transparent; }
.btn-danger-ghost:hover { background: rgba(229, 72, 77, 0.1); }

/* ---------------- 空状态 ---------------- */

.empty {
  padding: 64px 24px;
  text-align: center;
  color: var(--text-3);
}
.empty-icon { width: 36px; height: 36px; margin: 0 auto 14px; opacity: 0.45; stroke-width: 1.4; }
.empty-title { font-size: var(--fs-base); color: var(--text-2); font-weight: 500; margin-bottom: 6px; }
.empty-text { font-size: var(--fs-sm); line-height: 1.7; }

.drop-end {
  margin-top: 6px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: var(--fs-sm);
  color: var(--text-3);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
}
.drop-end.drop-over {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------------- 弹窗 ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh 20px 24px;
  background: rgba(15, 18, 25, 0.42);
  backdrop-filter: blur(2px);
  animation: fade-in 0.12s ease-out;
}
html[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.55); }

.modal {
  width: min(560px, 100%);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: modal-in 0.14s ease-out;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 14px 8px 20px;
}
.modal-head h2 { margin: 0; font-size: var(--fs-base); font-weight: 600; }
.modal-hint {
  margin: 0;
  padding: 0 20px 6px;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-3);
}
.modal-body { padding: 6px 20px 20px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 18px;
}

/* 导出 Markdown */
.export-section { margin-top: 14px; }
.export-section:first-child { margin-top: 2px; }
.export-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.export-label span { font-size: 11px; }
.export-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.export-chip {
  height: 27px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-2);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.export-chip:hover { border-color: var(--border-strong); }
.export-chip.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.export-dates {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.export-dates[hidden] { display: none; }
.export-dates .control { flex: 1; min-width: 0; }
.export-dash { font-size: var(--fs-xs); color: var(--text-3); }
.export-summary {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.export-summary strong { color: var(--text); font-weight: 600; }
.export-summary span { display: block; margin-top: 2px; font-size: var(--fs-xs); color: var(--text-3); }
.export-empty { align-self: center; font-size: var(--fs-xs); color: var(--text-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 导入 Markdown */
.import-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.import-count strong,
.import-skip strong { color: var(--text); font-weight: 600; }
.import-skip { font-size: var(--fs-xs); color: var(--text-3); }
.import-files { font-size: var(--fs-xs); color: var(--text-3); word-break: break-all; }
.import-list {
  list-style: none;
  max-height: 220px;
  margin: 10px 0 0;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.import-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  border-top: 1px solid var(--border);
}
.import-row:first-child { border-top: 0; }
.import-row.is-skip { color: var(--text-3); }
.import-badge {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
}
.import-row.is-skip .import-badge { background: var(--bg-hover); color: var(--text-3); }
.import-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-more { margin-top: 6px; font-size: var(--fs-xs); color: var(--text-3); }
.import-empty { margin: 10px 0 0; font-size: var(--fs-sm); color: var(--text-3); }

.confirm-text {
  margin: 4px 0 0;
  font-size: var(--fs-sm);
  line-height: 1.75;
  color: var(--text-2);
}

.manage-list { margin-top: 6px; }
.manage-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.manage-row:last-child { border-bottom: 0; }
.row-count { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.row-lock {
  font-size: var(--fs-xs);
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 6px;
  line-height: 18px;
  white-space: nowrap;
  justify-self: end;
}
.row-del { width: 26px; height: 26px; justify-self: end; }
.row-del:hover { color: var(--danger); }

.row-input {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-sm);
  outline: none;
}
.row-input:hover { border-color: var(--border); }
.row-input:focus {
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.manage-add {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}

.color-input {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 0; border-radius: 50%; }
.color-input::-moz-color-swatch { border: 0; border-radius: 50%; }

/* ---------------- 提示 ---------------- */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  max-width: min(460px, 90vw);
  padding: 9px 16px;
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: #fff;
  background: #23272f;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.18s ease-out;
  word-break: break-word;
}
html[data-theme="dark"] .toast { background: #2b303a; }
.toast-out { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }

.conflict-banner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 420;
  width: min(760px, calc(100% - 24px));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.conflict-banner[hidden] { display: none; }
.conflict-banner .btn { flex: 0 0 auto; }

.fatal-banner {  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  padding: 9px 16px;
  font-size: var(--fs-sm);
  color: #fff;
  background: var(--danger);
  text-align: center;
}

/* ---------------- 动效 ---------------- */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(-6px) scale(0.99); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1240px) {
  .workspace { grid-template-columns: 208px minmax(0, 1fr); }
  .main { padding: 24px 26px 100px; }
  .topbar-tools { gap: 6px; }
}

@media (max-width: 960px) {
  .main { padding: 20px 18px 90px; }
  .list:has(.task-item.expanded) { padding-bottom: 32vh; }
  .task-expand { padding: 12px 14px 14px 16px; }
  .subtask-strip { padding-left: 50px; }
  .card-actions { opacity: 1; pointer-events: auto; }
  .subtask-del { opacity: 1; }
  .attach-del { opacity: 1; }
  .note-bar { opacity: 1; }
  .quick-add > input { padding-right: 120px; }
  .qa-tool-label { display: none; }
  .qa-tool { padding: 0 6px; }
  .topbar { gap: 6px; padding: 0 10px; }
  .topbar-tools { gap: 3px; }
  .nt-colors { gap: 2px; }
  .nt-color { width: 12px; height: 12px; }
  .nt-sizes button { padding: 2px 4px; }
  .nt-clear { padding: 0 4px; }
  .theme-label { display: none; }
  .theme-chevron { display: none; }
  .theme-btn { padding: 0 7px; }
  .theme-menu { left: auto; right: 0; }
}

@media (max-width: 880px) {
  .nt-clear { display: none; }
  .tb-sep { display: none; }
  .nt-color { width: 13px; height: 13px; }
}

@media (max-width: 760px) {
  .subtask-list { grid-template-columns: 1fr; }
  .subtask-strip { padding-left: 44px; }
}

@media (max-width: 820px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .brand-tag { display: none; }
  .search { max-width: none; margin-left: 0; }
  .search-kbd { display: none; }
  .segment button { padding: 5px 9px; }
  .workspace { grid-template-columns: 172px minmax(0, 1fr); }
  .sidebar { padding: 10px 8px 12px; }
  .main { padding: 18px 14px 80px; }
  .editor-row input[type="date"] { flex: 1 1 100%; }
  .theme-chevron { display: none; }
}

.mobile-menu-btn { display: none; }
.mobile-sort-btn { display: none; }
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 290;
  background: rgba(15, 23, 42, 0.38);
}
.sidebar-backdrop[hidden] { display: none; }

@media (max-width: 700px) {
  .mobile-menu-btn { display: grid; order: -1; }
  .mobile-sort-btn { display: grid !important; }
  .topbar {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 6px 10px;
    row-gap: 6px;
  }
  .brand { order: 0; }
  .brand-tag { display: none; }
  .search { order: 4; flex: 1 1 100%; max-width: none; margin: 0; }
  .search-kbd { display: none; }
  .topbar-tools {
    order: 5;
    flex: 1 1 100%;
    width: 100%;
    overflow-x: auto;
    padding: 2px 0 1px;
    border-top: 1px solid var(--border);
  }
  .theme-switch { order: 2; margin-left: auto; }
  .topbar-right { order: 3; margin-left: 0; gap: 6px; }
  .topbar-right .segment { overflow-x: auto; }
  .segment button { padding: 5px 8px; white-space: nowrap; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    z-index: 300;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.18s ease-out;
    box-shadow: 8px 0 28px rgba(15, 23, 42, 0.18);
  }
  .sidebar.open { transform: none; }
  body.sidebar-open { overflow: hidden; }
  .main { padding: 14px 12px calc(90px + env(safe-area-inset-bottom)); }
  .main-inner { max-width: none; }
  .main-head { align-items: flex-start; gap: 8px; }
  .list:has(.task-item.expanded) { padding-bottom: 28vh; }
  .task-card { grid-template-columns: 14px 20px minmax(0, 1fr); }
  .card-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    max-width: none;
    justify-content: flex-start;
    margin-top: 3px;
  }
  .subtask-strip { grid-column: 1 / -1; grid-row: 3; padding-left: 8px; }
  .card-title { font-size: 17px; }
  .card-actions .qa-tool { min-height: 30px; }
  .subtask-add { gap: 5px; }
  .subtask-input { max-width: 100%; flex-basis: 100%; }
  .subtask-actions { width: 100%; margin-left: 0; justify-content: flex-end; }
  .note-editor { max-height: 50vh; }
  .topbar-tools .nt-colors { flex-wrap: nowrap; }
  .topbar-tools .nt-sizes { flex-wrap: nowrap; }
  .quick-add > input { padding-right: 104px; }
  .task-expand { padding: 10px 10px 12px 12px; }
  .note-item { padding: 8px 9px; }
}
