/* ==========================================================================
   PlanTrack — 设计系统
   亮/暗双主题 · 桌面/平板/移动三档响应式 · 安全区适配
   ========================================================================== */

/* ── 1. 设计令牌 ───────────────────────────────────────────────────────── */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg:            #f5f6f8;
  --bg-elev:       #ffffff;
  --bg-sunken:     #eceef2;
  --bg-hover:      #f0f2f6;
  --bg-active:     #e7eaf1;
  --bg-glass:      rgba(255,255,255,.78);

  --border:        #e2e5ec;
  --border-strong: #ccd1dc;
  --border-focus:  #a5b4fc;

  --text:          #14161b;
  --text-2:        #4d5566;
  --text-3:        #838c9e;
  --text-invert:   #ffffff;

  --accent:        #4f46e5;
  --accent-hover:  #4338ca;
  --accent-weak:   #eef0ff;
  --accent-weak-2: #e0e3ff;
  --accent-text:   #4338ca;
  --accent-ring:   rgba(79,70,229,.28);

  --q1: #dc2626;  --q1-weak: #fee2e2;  --q1-text: #b91c1c;
  --q2: #2563eb;  --q2-weak: #dbeafe;  --q2-text: #1d4ed8;
  --q3: #d97706;  --q3-weak: #fef3c7;  --q3-text: #b45309;
  --q4: #64748b;  --q4-weak: #eef1f5;  --q4-text: #475569;

  --ok:    #059669;  --ok-weak: #d1fae5;
  --warn:  #d97706;  --warn-weak: #fef3c7;
  --danger:#dc2626;  --danger-weak: #fee2e2;
  --info:  #2563eb;

  --r-xs: 5px; --r-sm: 7px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;

  --sh-1: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --sh-2: 0 2px 6px rgba(16,24,40,.06), 0 6px 16px rgba(16,24,40,.07);
  --sh-3: 0 12px 32px rgba(16,24,40,.14), 0 3px 8px rgba(16,24,40,.06);
  --sh-4: 0 24px 60px rgba(16,24,40,.20);

  --topbar-h: 56px;
  --sidebar-w: 248px;
  --tabbar-h: 58px;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --dur: 180ms;

  color-scheme: light;
}

html[data-theme="dark"] {
  --bg:            #0e1015;
  --bg-elev:       #161922;
  --bg-sunken:     #0a0c11;
  --bg-hover:      #1d2130;
  --bg-active:     #252a3b;
  --bg-glass:      rgba(22,25,34,.80);

  --border:        #262b39;
  --border-strong: #384054;
  --border-focus:  #4f46e5;

  --text:          #e8eaf0;
  --text-2:        #a4acc0;
  --text-3:        #6d7688;
  --text-invert:   #0e1015;

  --accent:        #7c7cf5;
  --accent-hover:  #9090ff;
  --accent-weak:   #1e2040;
  --accent-weak-2: #292b56;
  --accent-text:   #a5a8ff;
  --accent-ring:   rgba(124,124,245,.34);

  --q1: #f87171;  --q1-weak: #3a1a1c;  --q1-text: #fca5a5;
  --q2: #60a5fa;  --q2-weak: #14263f;  --q2-text: #93c5fd;
  --q3: #fbbf24;  --q3-weak: #362a10;  --q3-text: #fcd34d;
  --q4: #94a3b8;  --q4-weak: #212734;  --q4-text: #b6c0cf;

  --ok:    #34d399;  --ok-weak: #0c2f26;
  --warn:  #fbbf24;  --warn-weak: #362a10;
  --danger:#f87171;  --danger-weak: #3a1a1c;
  --info:  #60a5fa;

  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 2px 8px rgba(0,0,0,.45);
  --sh-3: 0 14px 36px rgba(0,0,0,.55);
  --sh-4: 0 28px 70px rgba(0,0,0,.65);

  color-scheme: dark;
}

/* ── 2. 基础重置 ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
h1,h2,h3,h4,h5,h6,p,figure,blockquote,dl,dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
svg.ic-fill { fill: currentColor; stroke: none; }
::selection { background: var(--accent-ring); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
[hidden] { display: none !important; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { left: 0; }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ── 3. 启动闪屏 ───────────────────────────────────────────────────────── */
.boot-splash {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--bg);
  transition: opacity 320ms var(--ease);
}
.boot-splash.is-gone { opacity: 0; pointer-events: none; }
.boot-mark { animation: bootPulse 1.6s var(--ease) infinite; }
.boot-text { color: var(--text-3); font-size: 13px; letter-spacing: .02em; }
@keyframes bootPulse { 0%,100% { transform: scale(1); opacity: 1 } 50% { transform: scale(.93); opacity: .68 } }

/* ── 4. 应用骨架 ───────────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-3) 0 var(--sp-4);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark { display: flex; }
.brand-text { font-weight: 680; font-size: 15px; letter-spacing: -.015em; color: var(--text); }

.quickadd-trigger {
  flex: 1; min-width: 0; max-width: 560px; height: 36px;
  display: flex; align-items: center; gap: 9px;
  padding: 0 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-3);
  font-size: 13px;
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
  text-align: left;
}
.quickadd-trigger:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.quickadd-trigger:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.qa-hint { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.icon-btn {
  width: 34px; height: 34px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-md); color: var(--text-2);
  transition: background var(--dur), color var(--dur);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { background: var(--bg-active); }
.icon-btn.is-on { color: var(--accent); background: var(--accent-weak); }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  color: var(--text-3); background: var(--bg-sunken);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--r-xs);
  line-height: 1; white-space: nowrap;
}

/* 同步状态胶囊 */
.sync-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; margin-right: 4px;
  border-radius: var(--r-full);
  background: var(--bg-sunken); border: 1px solid var(--border);
  font-size: 11.5px; font-weight: 550; color: var(--text-2);
  cursor: pointer; user-select: none;
  transition: background var(--dur);
}
.sync-pill:hover { background: var(--bg-hover); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.sync-pill[data-state="offline"] .sync-dot { background: var(--warn); }
.sync-pill[data-state="syncing"] .sync-dot { background: var(--info); animation: pulseDot 1.1s ease-in-out infinite; }
.sync-pill[data-state="synced"]  .sync-dot { background: var(--ok); }
.sync-pill[data-state="error"]   .sync-dot { background: var(--danger); }
.sync-pill[data-state="local"]   .sync-dot { background: var(--text-3); }
.sync-pill[data-state="syncing"] { color: var(--info); }
.sync-pill[data-state="synced"]  { color: var(--ok); }
.sync-pill[data-state="error"]   { color: var(--danger); }
@keyframes pulseDot { 0%,100% { opacity: 1 } 50% { opacity: .28 } }

/* ── 5. 布局 ───────────────────────────────────────────────────────────── */
.layout { flex: 1; display: flex; min-height: 0; position: relative; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden;
  padding: var(--sp-3) var(--sp-2) var(--sp-3);
  gap: 2px;
}
.sidebar-scrim {
  position: fixed; inset: 0; z-index: 44;
  background: rgba(12,14,20,.42); backdrop-filter: blur(2px);
  animation: fadeIn 160ms var(--ease);
}

.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: background var(--dur), color var(--dur);
  text-align: left; width: 100%;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.is-active { background: var(--accent-weak); color: var(--accent-text); font-weight: 600; }
.nav-item.is-active .ic { stroke-width: 1.9; }
.nav-item span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge {
  flex: none; min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; font-family: var(--font-mono);
  background: var(--accent); color: #fff; border-radius: var(--r-full);
}
.nav-badge.is-warn { background: var(--q1); }

.nav-sep { height: 1px; background: var(--border); margin: var(--sp-3) var(--sp-3); flex: none; }

.nav-section { display: flex; flex-direction: column; gap: 1px; min-height: 0; }
.nav-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 6px; font-size: 11px; font-weight: 650;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
}
.mini-btn {
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-xs); color: var(--text-3);
}
.mini-btn:hover { background: var(--bg-hover); color: var(--accent); }
.mini-btn svg.ic { width: 14px; height: 14px; }

.goal-list { display: flex; flex-direction: column; gap: 1px; }
.goal-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--r-md);
  color: var(--text-2); font-size: 13px; text-align: left; width: 100%;
  transition: background var(--dur);
}
.goal-chip:hover { background: var(--bg-hover); color: var(--text); }
.goal-chip.is-active { background: var(--bg-active); color: var(--text); }
.goal-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.goal-chip-body { flex: 1; min-width: 0; }
.goal-chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.goal-chip-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.goal-mini-bar { flex: 1; height: 3px; background: var(--bg-sunken); border-radius: 99px; overflow: hidden; }
.goal-mini-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width 400ms var(--ease); }
.goal-chip-pct { font-family: var(--font-mono); font-size: 10px; color: var(--text-3); flex: none; }

.sidebar-foot { margin-top: auto; padding: var(--sp-4) var(--sp-3) 0; flex: none; }
.storage-hint { font-size: 11px; color: var(--text-3); line-height: 1.6; }
.storage-bar { height: 3px; background: var(--bg-sunken); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.storage-fill { height: 100%; background: var(--accent); border-radius: 99px; }

.main { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.main:focus { outline: none; }

/* ── 6. 页面容器 ───────────────────────────────────────────────────────── */
.page { padding: var(--sp-5) var(--sp-6) 96px; max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-head-main { flex: 1; min-width: 240px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.page-sub { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* ── 7. 按钮 ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 570;
  border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text);
  transition: background var(--dur), border-color var(--dur), box-shadow var(--dur), transform 80ms;
  white-space: nowrap; flex: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg.ic { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--sh-1); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-weak); border-color: var(--danger); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-sm svg.ic { width: 13px; height: 13px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 14px; }

.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--bg-sunken); border-radius: var(--r-md); border: 1px solid var(--border);
}
.seg button {
  height: 26px; padding: 0 11px; border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 550; color: var(--text-2);
  transition: background var(--dur), color var(--dur);
}
.seg button:hover { color: var(--text); }
.seg button.is-on { background: var(--bg-elev); color: var(--text); box-shadow: var(--sh-1); font-weight: 620; }

/* ── 8. 卡片 / 面板 ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 13.5px; font-weight: 650; display: flex; align-items: center; gap: 7px; }
.card-title svg.ic { width: 15px; height: 15px; color: var(--text-3); }
.card-body { padding: var(--sp-4); }
.card-head-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* ── 9. 网格 ───────────────────────────────────────────────────────────── */
.grid { display: grid; gap: var(--sp-4); }
.grid-dash { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ── 10. 统计卡 ────────────────────────────────────────────────────────── */
.stat {
  padding: var(--sp-4);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg);
  position: relative; overflow: hidden;
}
.stat-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); letter-spacing: .03em; text-transform: uppercase; }
.stat-value { font-size: 26px; font-weight: 720; letter-spacing: -.03em; margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-value small { font-size: 14px; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.stat-foot { font-size: 11.5px; color: var(--text-3); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.stat.is-accent { border-color: var(--accent); background: linear-gradient(160deg, var(--accent-weak), var(--bg-elev) 70%); }
.stat-bar { height: 4px; border-radius: 99px; background: var(--bg-sunken); overflow: hidden; margin-top: 10px; }
.stat-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width 500ms var(--ease); }
.trend-up { color: var(--ok); } .trend-down { color: var(--danger); }

/* ── 11. 任务行 ────────────────────────────────────────────────────────── */
.task-list { display: flex; flex-direction: column; }
.task-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-md);
  transition: background var(--dur);
  position: relative; cursor: pointer;
}
.task-row:hover { background: var(--bg-hover); }
.task-row.is-selected { background: var(--accent-weak); }
.task-row.is-done .task-title { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-strong); }

.check {
  width: 17px; height: 17px; flex: none; margin-top: 2px;
  border: 1.8px solid var(--border-strong); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur), border-color var(--dur), transform 120ms;
  background: var(--bg-elev);
}
.check:hover { border-color: var(--accent); transform: scale(1.1); }
.check svg { width: 11px; height: 11px; stroke: #fff; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity 120ms; }
.task-row.is-done .check { background: var(--ok); border-color: var(--ok); }
.task-row.is-done .check svg { opacity: 1; }
.task-row.is-doing .check { border-color: var(--info); background: var(--q2-weak); }
.task-row.is-blocked .check { border-color: var(--warn); }

.task-main { flex: 1; min-width: 0; }
.task-title { font-size: 13.5px; font-weight: 500; line-height: 1.45; word-break: break-word; }
.task-meta { display: flex; align-items: center; gap: 7px; margin-top: 4px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); }
.task-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }

.tag {
  display: inline-flex; align-items: center; gap: 3px;
  height: 18px; padding: 0 6px; border-radius: var(--r-xs);
  font-size: 10.5px; font-weight: 600;
  background: var(--bg-sunken); color: var(--text-2);
  white-space: nowrap;
}
.tag.q1 { background: var(--q1-weak); color: var(--q1-text); }
.tag.q2 { background: var(--q2-weak); color: var(--q2-text); }
.tag.q3 { background: var(--q3-weak); color: var(--q3-text); }
.tag.q4 { background: var(--q4-weak); color: var(--q4-text); }
.tag.ok { background: var(--ok-weak); color: var(--ok); }
.tag.warn { background: var(--warn-weak); color: var(--warn); }
.tag.danger { background: var(--danger-weak); color: var(--danger); }
.tag.accent { background: var(--accent-weak); color: var(--accent-text); }

.due {
  display: inline-flex; align-items: center; gap: 3px;
  font-variant-numeric: tabular-nums;
}
.due svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.due.is-overdue { color: var(--danger); font-weight: 650; }
.due.is-today { color: var(--accent-text); font-weight: 650; }
.due.is-soon { color: var(--warn); font-weight: 600; }

.task-side { display: flex; align-items: center; gap: 2px; flex: none; opacity: 0; transition: opacity var(--dur); }
.task-row:hover .task-side, .task-row:focus-within .task-side { opacity: 1; }
@media (hover: none) { .task-side { opacity: 1; } }
.task-side .icon-btn { width: 26px; height: 26px; }
.task-side .icon-btn svg.ic { width: 14px; height: 14px; }

.pri-pip {
  width: 3px; height: 20px; border-radius: 99px; flex: none;
  margin-top: 1px;
}

/* ── 12. 目标树 ────────────────────────────────────────────────────────── */
.tree { display: flex; flex-direction: column; gap: var(--sp-3); }
.tree-node {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-1); overflow: hidden;
  transition: box-shadow var(--dur), border-color var(--dur);
}
.tree-node:hover { box-shadow: var(--sh-2); }
.tree-node.is-focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.tree-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
}
.tree-head:hover { background: var(--bg-hover); }
.tree-caret {
  width: 20px; height: 20px; flex: none; margin-top: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-xs); color: var(--text-3);
  transition: transform var(--dur), background var(--dur);
}
.tree-caret:hover { background: var(--bg-active); }
.tree-caret svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tree-node.is-open > .tree-head .tree-caret { transform: rotate(90deg); }
.tree-node.is-leaf > .tree-head .tree-caret { visibility: hidden; }
.tree-head-body { flex: 1; min-width: 0; }
.tree-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tree-title { font-size: 14.5px; font-weight: 640; letter-spacing: -.01em; }
.tree-node[data-depth="1"] .tree-title { font-size: 13.5px; font-weight: 580; }
.tree-node[data-depth="2"] .tree-title { font-size: 13px; font-weight: 520; }
.tree-desc { font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }
.tree-progress { display: flex; align-items: center; gap: 8px; margin-top: 8px; max-width: 420px; }
.progress-bar { flex: 1; height: 5px; background: var(--bg-sunken); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 460ms var(--ease); background: var(--accent); }
.progress-pct { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-2); flex: none; min-width: 30px; text-align: right; }

.tree-children {
  border-top: 1px solid var(--border);
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  background: var(--bg-sunken);
  display: flex; flex-direction: column; gap: 2px;
}
.tree-node[data-depth="1"] .tree-children { background: transparent; padding-left: var(--sp-5); border-top: 0; }
.tree-child {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--r-md);
  cursor: pointer; transition: background var(--dur);
}
.tree-child:hover { background: var(--bg-hover); }
.tree-child.is-done .tree-child-title { color: var(--text-3); text-decoration: line-through; }
.tree-child-title { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-child-meta { display: flex; align-items: center; gap: 6px; flex: none; font-size: 11px; color: var(--text-3); }
.tree-add {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; border-radius: var(--r-md);
  color: var(--text-3); font-size: 12.5px; width: 100%;
  border: 1px dashed transparent; transition: all var(--dur);
}
.tree-add:hover { color: var(--accent-text); background: var(--accent-weak); border-color: var(--accent); border-style: dashed; }

/* ── 13. 日历 ──────────────────────────────────────────────────────────── */
.cal-wrap { display: flex; flex-direction: column; gap: var(--sp-3); }
.cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  padding: 0 0 var(--sp-2);
}
.cal-dow > div {
  text-align: center; font-size: 11px; font-weight: 650; color: var(--text-3);
  letter-spacing: .04em; text-transform: uppercase; padding: 4px 0;
}
.cal-dow > div.is-weekend { color: var(--q1-text); opacity: .8; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
}
.cal-cell {
  background: var(--bg-elev); min-height: 112px; padding: 6px;
  display: flex; flex-direction: column; gap: 3px;
  transition: background var(--dur);
  position: relative;
}
.cal-cell.is-out { background: var(--bg-sunken); }
.cal-cell.is-out .cal-date { color: var(--text-3); opacity: .5; }
.cal-cell.is-drop { background: var(--accent-weak); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.is-today { background: var(--accent-weak); }
.cal-date {
  font-size: 12px; font-weight: 620; color: var(--text-2);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  padding: 1px 3px; min-height: 20px;
}
.cal-cell.is-today .cal-date { color: var(--accent-text); }
.cal-date-num { display: inline-flex; align-items: center; justify-content: center; min-width: 21px; height: 21px; border-radius: 50%; }
.cal-cell.is-today .cal-date-num { background: var(--accent); color: #fff; font-weight: 700; }
.cal-load { font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; padding: 1px 4px; border-radius: var(--r-xs); }
.cal-load.l1 { background: var(--q2-weak); color: var(--q2-text); }
.cal-load.l2 { background: var(--q3-weak); color: var(--q3-text); }
.cal-load.l3 { background: var(--q1-weak); color: var(--q1-text); }
.cal-tasks { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-task {
  display: flex; align-items: center; gap: 4px;
  padding: 2px 5px; border-radius: var(--r-xs);
  font-size: 11.5px; line-height: 1.4;
  background: var(--bg-sunken); color: var(--text-2);
  cursor: grab; user-select: none;
  border-left: 2.5px solid var(--border-strong);
  overflow: hidden;
}
.cal-task:hover { background: var(--bg-active); }
.cal-task:active { cursor: grabbing; }
.cal-task.is-dragging { opacity: .4; }
.cal-task.is-done { opacity: .5; text-decoration: line-through; }
.cal-task.q1 { border-left-color: var(--q1); background: var(--q1-weak); color: var(--q1-text); }
.cal-task.q2 { border-left-color: var(--q2); background: var(--q2-weak); color: var(--q2-text); }
.cal-task.q3 { border-left-color: var(--q3); background: var(--q3-weak); color: var(--q3-text); }
.cal-task.q4 { border-left-color: var(--q4); background: var(--q4-weak); color: var(--q4-text); }
.cal-task-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.cal-more { font-size: 10.5px; color: var(--text-3); padding-left: 4px; font-weight: 600; }

/* 周视图 */
.cal-week { display: flex; flex-direction: column; gap: 6px; }
.week-row {
  display: grid; grid-template-columns: 64px 1fr; gap: 10px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 8px 10px; min-height: 62px;
}
.week-row.is-today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.week-day { display: flex; flex-direction: column; justify-content: center; }
.week-dow { font-size: 11px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.week-num { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.week-row.is-today .week-num { color: var(--accent-text); }
.week-tasks { display: flex; flex-direction: column; gap: 3px; }

/* ── 14. 紧急·重要矩阵 ─────────────────────────────────────────────────── */
.matrix-layout { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: var(--sp-4); align-items: start; }
.matrix-stage {
  position: relative;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: 0;
  overflow: visible;
}
/* 画布：始终正方形，取「容器可用宽」与「视口可用高」中较小的那个，
   两边各留 --matrix-side 的余量给贴边的圆点，避免被裁。
   --matrix-room 只扣掉顶栏 + 页头 + 上下边距，把高度尽量留给画布。 */
.matrix-canvas {
  --matrix-side: 68px;
  --matrix-room: calc(100dvh - 150px);
  position: relative;
  width: min(calc(100% - var(--matrix-side) * 2), var(--matrix-room));
  aspect-ratio: 1 / 1;
  margin: 16px auto 28px;
  background:
    linear-gradient(to right, var(--border) 1px, transparent 1px) 0 0 / 10% 100%,
    linear-gradient(to bottom, var(--border) 1px, transparent 1px) 0 0 / 100% 10%;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  touch-action: none;
}
.matrix-quad {
  position: absolute; width: 50%; height: 50%;
  pointer-events: none;
}
.matrix-quad.q2 { top: 0; left: 0; background: var(--q2-weak); }
.matrix-quad.q1 { top: 0; right: 0; background: var(--q1-weak); }
.matrix-quad.q4 { bottom: 0; left: 0; background: var(--q4-weak); }
.matrix-quad.q3 { bottom: 0; right: 0; background: var(--q3-weak); }
.matrix-quad-label {
  position: absolute; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 4px 8px; border-radius: var(--r-xs); pointer-events: none;
  opacity: .95; display: flex; flex-direction: column; gap: 1px;
  z-index: 8;
}
.matrix-quad-label > span { display: inline-flex; align-items: center; gap: 4px; }
.matrix-quad-label svg { width: 13px; height: 13px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.matrix-quad-label small { font-size: 9.5px; font-weight: 500; opacity: .8; letter-spacing: 0; }
.matrix-quad-label.q1 { top: 8px; right: 8px; color: var(--q1-text); background: var(--q1-weak); }
.matrix-quad-label.q2 { top: 8px; left: 8px;  color: var(--q2-text); background: var(--q2-weak); }
.matrix-quad-label.q3 { bottom: 8px; right: 8px; color: var(--q3-text); background: var(--q3-weak); }
.matrix-quad-label.q4 { bottom: 8px; left: 8px;  color: var(--q4-text); background: var(--q4-weak); }

.matrix-axis { position: absolute; font-size: 11px; font-weight: 650; color: var(--text-3); letter-spacing: .05em; text-transform: uppercase; }
.matrix-axis.axis-x { bottom: 16px; left: 50%; transform: translateX(-50%); }
.matrix-axis.axis-y { left: 12px; top: 50%; transform: translateY(-50%) rotate(-90deg); white-space: nowrap; }
.matrix-tick { position: absolute; font-size: 10px; font-family: var(--font-mono); color: var(--text-3); }
.matrix-tick.tx { bottom: 4px; transform: translateX(-50%); }
.matrix-tick.ty { left: 4px; transform: translateY(50%); }
.matrix-mid-x { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--border-strong); pointer-events: none; }
.matrix-mid-y { position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border-strong); pointer-events: none; }

.dot {
  position: absolute;
  transform: translate(-50%, 50%);
  display: flex; align-items: center; gap: 4px;
  padding: 2px 7px 2px 5px;
  border-radius: var(--r-full);
  background: var(--bg-elev);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--sh-1);
  cursor: grab; user-select: none; white-space: nowrap;
  font-size: 10.5px; font-weight: 560;
  transition: box-shadow var(--dur), transform 90ms var(--ease), opacity var(--dur);
  touch-action: none;
  z-index: 2;
}
.dot:hover { box-shadow: var(--sh-2); z-index: 30; }
.dot:focus-visible { z-index: 30; }
.dot.is-drag { cursor: grabbing; box-shadow: var(--sh-3); z-index: 40; transform: translate(-50%, 50%) scale(1.06); }
.dot.is-done { opacity: .45; }
.dot.is-done .dot-text { text-decoration: line-through; }
.dot-pip { width: 7px; height: 7px; border-radius: 50%; flex: none; }
/* 静止时只露前几个字，悬停展开全文——这是「不糊成一片」的关键 */
.dot-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 88px;
  transition: max-width 150ms var(--ease);
}
.dot:hover .dot-text, .dot:focus-visible .dot-text { max-width: 320px; }

/* 圆点模式：只剩一个点，悬停才出标签。
   悬停时只横向展开文本、不改内边距，避免指针被「缩出去」造成闪烁。 */
.dot.is-pip { padding: 4px; }
.dot.is-pip .dot-pip { width: 10px; height: 10px; }
.dot.is-pip .dot-text { max-width: 0; opacity: 0; }
.dot.is-pip:hover .dot-text, .dot.is-pip:focus-visible .dot-text { max-width: 320px; opacity: 1; }

/* 悬停时压低其余圆点，直接解决「看不出在指哪一个」 */
.matrix-canvas:has(.dot:hover) .dot:not(:hover) { opacity: .32; }
.matrix-canvas:has(.dot:hover) .dot.is-done:not(:hover) { opacity: .18; }
.matrix-canvas:has(.dot:focus-visible) .dot:not(:focus-visible) { opacity: .32; }

.dot.q1 { border-color: var(--q1); } .dot.q1 .dot-pip { background: var(--q1); }
.dot.q2 { border-color: var(--q2); } .dot.q2 .dot-pip { background: var(--q2); }
.dot.q3 { border-color: var(--q3); } .dot.q3 .dot-pip { background: var(--q3); }
.dot.q4 { border-color: var(--q4); } .dot.q4 .dot-pip { background: var(--q4); }

.matrix-side { display: flex; flex-direction: column; gap: var(--sp-3); position: sticky; top: var(--sp-4); }
.quad-card { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--bg-elev); }
.quad-card.q1 { border-left: 3px solid var(--q1); }
.quad-card.q2 { border-left: 3px solid var(--q2); }
.quad-card.q3 { border-left: 3px solid var(--q3); }
.quad-card.q4 { border-left: 3px solid var(--q4); }
.quad-card-head { display: flex; align-items: center; gap: 8px; }
.quad-card-name { font-size: 13px; font-weight: 660; }
.quad-card-count { margin-left: auto; font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--text-3); }
.quad-card-tip { font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }
.quad-card-list { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.quad-card-item {
  font-size: 12.5px; padding: 4px 6px; border-radius: var(--r-xs);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
  color: var(--text-2);
}
.quad-card-item:hover { background: var(--bg-hover); color: var(--text); }

/* ── 15. 抽屉 ──────────────────────────────────────────────────────────── */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12,14,20,.34); backdrop-filter: blur(2px);
  animation: fadeIn 180ms var(--ease);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(520px, 100vw);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: var(--sh-4);
  display: flex; flex-direction: column;
  animation: slideInRight 240ms var(--ease);
  padding-top: env(safe-area-inset-top);
}
@keyframes slideInRight { from { transform: translateX(24px); opacity: .4 } to { transform: none; opacity: 1 } }
.drawer-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); flex: none;
}
.drawer-head-title { font-size: 12px; font-weight: 650; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-5) var(--sp-5) 40px; }
.drawer-foot {
  flex: none; padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-2);
  padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom));
}

/* ── 16. 表单 ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field-label { font-size: 12px; font-weight: 620; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field-label .hint { font-weight: 400; color: var(--text-3); font-size: 11px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

.input, .textarea, .select {
  width: 100%; padding: 8px 11px;
  background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 13.5px; color: var(--text);
  transition: border-color var(--dur), box-shadow var(--dur);
  -webkit-appearance: none; appearance: none;
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 76px; line-height: 1.6; font-family: inherit; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23838c9e' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px;
  padding-right: 30px;
}
.input-title { font-size: 16px; font-weight: 620; padding: 10px 12px; letter-spacing: -.01em; }
.input-sm { padding: 6px 9px; font-size: 12.5px; }

.range-row { display: flex; align-items: center; gap: 10px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 4px; border-radius: 99px; background: var(--bg-sunken); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-elev);
  box-shadow: var(--sh-1); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--bg-elev);
  background: var(--accent); box-shadow: var(--sh-1); cursor: pointer;
}
.range-val { font-family: var(--font-mono); font-size: 12px; font-weight: 700; width: 34px; text-align: right; color: var(--text-2); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 10px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 550;
  background: var(--bg-sunken); color: var(--text-2);
  border: 1px solid transparent;
  transition: all var(--dur);
}
.chip:hover { background: var(--bg-active); color: var(--text); }
.chip.is-on { background: var(--accent-weak); color: var(--accent-text); border-color: var(--accent); }
.chip input { display: none; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch-track {
  width: 38px; height: 22px; border-radius: 99px; flex: none;
  background: var(--border-strong); position: relative;
  transition: background var(--dur);
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: var(--sh-1); transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch-text { font-size: 13px; }
.switch-desc { font-size: 11.5px; color: var(--text-3); }

/* ── 17. 命令面板 ──────────────────────────────────────────────────────── */
.palette-scrim {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(12,14,20,.36); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(12vh, 60px) var(--sp-4) var(--sp-4);
  animation: fadeIn 140ms var(--ease);
}
.palette {
  width: min(660px, 100%);
  max-height: min(70vh, 620px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-4);
  display: flex; flex-direction: column; overflow: hidden;
  animation: paletteIn 200ms var(--ease);
}
@keyframes paletteIn { from { transform: translateY(-10px) scale(.985); opacity: 0 } to { transform: none; opacity: 1 } }
.palette-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.palette-ic { color: var(--text-3); width: 19px; height: 19px; }
.palette-input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-size: 15.5px; font-weight: 500; letter-spacing: -.01em;
}
.palette-hint {
  padding: 8px var(--sp-4); font-size: 11.5px; color: var(--text-3);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: var(--bg-sunken);
}
.palette-hint:empty { display: none; }
.palette-results { flex: 1; overflow-y: auto; padding: 6px; }
.palette-group-label {
  font-size: 10.5px; font-weight: 700; color: var(--text-3);
  letter-spacing: .07em; text-transform: uppercase;
  padding: 8px 10px 4px;
}
.palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-md);
  cursor: pointer; width: 100%; text-align: left;
}
.palette-item:hover, .palette-item.is-active { background: var(--bg-hover); }
.palette-item.is-active { background: var(--accent-weak); }
.palette-item-icon {
  width: 26px; height: 26px; flex: none; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-sunken); color: var(--text-2);
}
.palette-item-icon svg.ic { width: 14px; height: 14px; }
.palette-item-body { flex: 1; min-width: 0; }
.palette-item-title { font-size: 13.5px; font-weight: 520; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item-sub { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.palette-item-key { font-size: 11px; color: var(--text-3); flex: none; }
.palette-empty { padding: 34px 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.palette-foot {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 8px var(--sp-4); border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-3); background: var(--bg-sunken);
}
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* ── 18. 弹窗 ──────────────────────────────────────────────────────────── */
.modal-scrim {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(12,14,20,.42); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  animation: fadeIn 160ms var(--ease);
}
.modal {
  width: min(560px, 100%); max-height: min(86vh, 760px);
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-4);
  display: flex; flex-direction: column; overflow: hidden;
  animation: paletteIn 200ms var(--ease);
}
.modal-head { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); flex: none; }
.modal-title { font-size: 16px; font-weight: 680; letter-spacing: -.015em; }
.modal-sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.modal-body { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.modal-foot {
  padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-2); flex: none;
  background: var(--bg-sunken);
}
.modal-foot .spacer { flex: 1; }

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

/* ── 19. Toast ─────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; z-index: 90;
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(440px, calc(100vw - 24px));
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-full);
  background: var(--text); color: var(--bg-elev);
  font-size: 13px; font-weight: 520;
  box-shadow: var(--sh-3);
  animation: toastIn 260ms var(--ease);
  pointer-events: auto; max-width: 100%;
}
.toast.is-out { animation: toastOut 200ms var(--ease) forwards; }
.toast svg.ic { width: 15px; height: 15px; flex: none; }
.toast.ok svg.ic { color: #34d399; }
.toast.err svg.ic { color: #f87171; }
.toast.warn svg.ic { color: #fbbf24; }
.toast-body { flex: 1; min-width: 0; }
.toast-action { font-size: 12.5px; font-weight: 650; color: #a5b4fc; flex: none; }
@keyframes toastIn { from { transform: translateY(14px) scale(.96); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes toastOut { to { transform: translateY(8px) scale(.97); opacity: 0 } }

/* ── 20. 空态 / 骨架 ───────────────────────────────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 56px 24px; text-align: center; color: var(--text-3);
}
.empty-icon {
  width: 52px; height: 52px; border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-sunken); color: var(--text-3); margin-bottom: 2px;
}
.empty-icon svg.ic { width: 26px; height: 26px; stroke-width: 1.5; }
.empty-title { font-size: 15px; font-weight: 620; color: var(--text-2); }
.empty-desc { font-size: 13px; max-width: 380px; line-height: 1.6; }
.empty-actions { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 50%, var(--bg-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0 } }

/* ── 21. AI 组件 ───────────────────────────────────────────────────────── */
.ai-badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 19px; padding: 0 7px; border-radius: var(--r-full);
  font-size: 10.5px; font-weight: 680; letter-spacing: .03em;
  background: linear-gradient(120deg, var(--accent), #8b5cf6);
  color: #fff; flex: none;
}
.ai-badge svg { width: 11px; height: 11px; fill: currentColor; stroke: none; }
.ai-panel {
  border: 1px solid var(--accent);
  background: linear-gradient(165deg, var(--accent-weak), var(--bg-elev) 62%);
  border-radius: var(--r-lg); padding: var(--sp-4);
}
.ai-panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: var(--sp-3); }
.ai-panel-title { font-size: 13.5px; font-weight: 660; }
.ai-steps { display: flex; flex-direction: column; gap: 1px; }
.ai-step {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 6px 8px; border-radius: var(--r-sm); font-size: 12.5px;
  color: var(--text-2);
}
.ai-step.is-active { background: var(--bg-elev); color: var(--text); font-weight: 550; }
.ai-step.is-done { color: var(--text-3); }
.ai-step-mark {
  width: 16px; height: 16px; flex: none; margin-top: 1px; border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; font-family: var(--font-mono);
}
.ai-step.is-active .ai-step-mark { border-color: var(--accent); background: var(--accent); color: #fff; }
.ai-step.is-done .ai-step-mark { border-color: var(--ok); background: var(--ok); color: #fff; }
.ai-spin { width: 13px; height: 13px; border: 2px solid var(--accent-weak-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg) } }

.insight {
  display: flex; align-items: flex-start; gap: 10px;
  padding: var(--sp-3); border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg-elev);
}
.insight-bar { width: 3px; align-self: stretch; border-radius: 99px; flex: none; background: var(--text-3); }
.insight.high .insight-bar { background: var(--q1); }
.insight.mid  .insight-bar { background: var(--q3); }
.insight.low  .insight-bar { background: var(--q2); }
.insight.ok   .insight-bar { background: var(--ok); }
.insight-body { flex: 1; min-width: 0; }
.insight-title { font-size: 13px; font-weight: 620; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.insight-text { font-size: 12.5px; color: var(--text-2); margin-top: 3px; line-height: 1.6; }
.insight-actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ── 22. 离线横幅 ──────────────────────────────────────────────────────── */
.offline-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--sp-3) + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: var(--r-full);
  background: var(--warn-weak); color: var(--q3-text);
  border: 1px solid var(--warn);
  font-size: 12px; font-weight: 560;
  box-shadow: var(--sh-2);
  animation: toastIn 240ms var(--ease);
  max-width: calc(100vw - 24px);
}
.offline-banner svg.ic { width: 14px; height: 14px; flex: none; }

/* ── 23. 工具类 ────────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-3); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }
.only-mobile { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.nowrap { white-space: nowrap; }

/* ── 24. 移动端标签栏 ──────────────────────────────────────────────────── */
.tabbar {
  display: none;
  flex: none; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  z-index: 45;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-3); font-size: 10.5px; font-weight: 570;
  transition: color var(--dur);
  padding: 4px 0;
}
.tab-item.is-active { color: var(--accent); }
.tab-item svg.ic { width: 20px; height: 20px; }
.tab-add { flex: none; width: 56px; }
.tab-add svg.ic {
  width: 38px; height: 38px; padding: 9px;
  background: var(--accent); color: #fff; border-radius: 50%;
  box-shadow: 0 4px 14px var(--accent-ring);
  stroke-width: 2.2;
  margin-top: -14px;
  transition: transform var(--dur);
}
.tab-add:active svg.ic { transform: scale(.94); }

/* ── 25. 响应式 ────────────────────────────────────────────────────────── */

/* 大屏桌面：加宽侧栏 */
@media (min-width: 1600px) {
  :root { --sidebar-w: 272px; }
  .page { padding-left: var(--sp-8); padding-right: var(--sp-8); }
}

/* 平板：侧栏收窄，矩阵单列（画布因此拿到整行宽度） */
@media (max-width: 1080px) {
  :root { --sidebar-w: 208px; }
  .matrix-layout { grid-template-columns: minmax(0,1fr); }
  .matrix-side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
  .page { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .matrix-canvas { --matrix-side: 60px; --matrix-room: calc(100dvh - 142px); margin: 14px auto 24px; }
}

/* 小屏平板 / 大屏手机：侧栏变抽屉 */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 45;
    width: 268px; transform: translateX(-102%);
    transition: transform 240ms var(--ease);
    box-shadow: var(--sh-4);
    padding-top: calc(var(--sp-3) + env(safe-area-inset-top));
    border-right: 1px solid var(--border);
  }
  .sidebar.is-open { transform: none; }
  .only-mobile { display: inline-flex !important; }
  .only-desktop { display: none !important; }
  .tabbar { display: flex; }
  .page { padding: var(--sp-4) var(--sp-4) 88px; }
  .quickadd-trigger { flex: none; width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 50%; }
  .quickadd-trigger .qa-hint { display: none; }
  .brand-text { display: none; }
  .page-title { font-size: 19px; }
  .grid-dash { grid-template-columns: 1fr; }
  .matrix-canvas { --matrix-side: 56px; --matrix-room: calc(100dvh - 152px); margin: 14px auto 24px; }
  .dot-text { max-width: 76px; }
  .offline-banner { bottom: calc(var(--tabbar-h) + var(--sp-2) + env(safe-area-inset-bottom)); }
}

/* 手机 */
@media (max-width: 640px) {
  body { font-size: 13.5px; }
  .page { padding: var(--sp-3) var(--sp-3) 88px; }
  .page-head { gap: var(--sp-3); margin-bottom: var(--sp-4); }
  .page-actions { width: 100%; }
  .field-row { grid-template-columns: 1fr; }
  .grid { gap: var(--sp-3); }
  .grid-stats { grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
  .stat { padding: var(--sp-3); }
  .stat-value { font-size: 21px; }
  .cal-cell { min-height: 78px; padding: 4px; }
  .cal-date { font-size: 11px; }
  .cal-task { font-size: 10.5px; padding: 1px 4px; }
  .cal-task-text { max-width: 62px; }
  .cal-dow > div { font-size: 10px; }
  .drawer { width: 100vw; border-left: 0; }
  .drawer-body { padding: var(--sp-4) var(--sp-4) 32px; }
  .modal { width: 100%; max-height: 92vh; border-radius: var(--r-lg); }
  .modal-scrim { padding: 0; align-items: flex-end; }
  .palette-scrim { padding: 0; align-items: stretch; }
  .palette { width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .palette-foot { display: none; }
  .matrix-canvas { --matrix-side: 48px; --matrix-room: calc(100dvh - 172px); margin: 12px auto 20px; }
  .matrix-quad-label { font-size: 9.5px; padding: 3px 5px; }
  .matrix-quad-label small { display: none; }
  .dot { font-size: 10px; padding: 2px 6px 2px 4px; }
  .dot-text { max-width: 64px; }
  .dot-pip { width: 6px; height: 6px; }
  .toasts { bottom: calc(var(--tabbar-h) + var(--sp-2) + env(safe-area-inset-bottom)); }
  .week-row { grid-template-columns: 52px 1fr; gap: 8px; padding: 7px 8px; }
  .week-num { font-size: 17px; }
  .tree-head { padding: var(--sp-3); }
  .tree-children { padding-left: var(--sp-3); }
  .task-row { padding: 8px; }
  .sync-label { display: none; }
  .sync-pill { padding: 0 8px; }
}

/* 横屏手机：压缩纵向空间 */
@media (max-height: 480px) and (orientation: landscape) {
  .tabbar { display: none; }
  :root { --topbar-h: 46px; }
  .page { padding-bottom: 40px; }
}

/* ── 26. 打印 ──────────────────────────────────────────────────────────── */
@media print {
  .topbar, .sidebar, .tabbar, .toasts, .drawer, .palette-scrim, .modal-scrim, .offline-banner, .page-actions, .task-side { display: none !important; }
  .app { height: auto; overflow: visible; }
  .main { overflow: visible; }
  .card, .tree-node, .stat { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
  .page { padding: 0; max-width: none; }
}

/* ── 27. 无障碍 / 动效偏好 ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
@media (prefers-contrast: more) {
  :root { --border: #9aa3b2; --border-strong: #6b7280; --text-3: #5b6373; }
}
