/* ===== 设计系统 ===== */
:root {
  --primary: #4F46E5;
  --primary-light: #818CF8;
  --primary-bg: #EEF2FF;
  --danger: #EF4444;
  --success: #10B981;
  --warning: #F59E0B;
  --text: #1F2937;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;
  --bg: #F8F9FB;
  --white: #FFFFFF;
  --border: #E5E7EB;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --radius: 10px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --ruler-w: 44px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { touch-action: manipulation; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* 防止 iOS modal 切换时滚位跳跃 */
  position: relative;
}

/* ===== 布局容器 ===== */
#app {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
  margin-bottom: 32px;
}
.sidebar-logo { font-size: 24px; }
.sidebar-title { font-size: 18px; font-weight: 700; color: var(--text); }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-secondary);
  transition: all 0.15s;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.sidebar-nav-item:hover { background: var(--bg); color: var(--text); }
.sidebar-nav-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.sidebar-nav-item svg { flex-shrink: 0; opacity: 0.7; }
.sidebar-spacer { flex: 1; }

.sidebar-weather {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 12px;
  font-size: 13px;
}
.weather-icon { font-size: 18px; }
.weather-temp { font-weight: 600; color: var(--text); }
.weather-city { color: var(--text-light); font-size: 11px; margin-left: auto; }

.sidebar-actions { display: flex; flex-direction: column; gap: 4px; }
/* 侧边栏认证 + 同步 */
.sidebar-auth { margin-bottom: 12px; }
.sidebar-auth-logged-out, .sidebar-auth-logged-in { width: 100%; }
.sidebar-auth-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1.5px dashed var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-secondary);
  transition: all 0.15s;
  text-align: left;
  min-height: 40px;
}
.sidebar-auth-btn:hover { border-color: var(--primary-light); color: var(--primary); background: var(--primary-bg); }
.sidebar-auth-btn svg { flex-shrink: 0; opacity: 0.7; }

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 6px;
}
.sidebar-user-avatar { font-size: 18px; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.sidebar-sync-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-secondary);
  transition: all 0.15s;
  min-height: 36px;
}
.sidebar-sync-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.sidebar-sync-btn.syncing { opacity: 0.7; pointer-events: none; }
.sidebar-sync-btn.syncing svg { animation: syncSpin 1s linear infinite; }
@keyframes syncSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.sidebar-sync-time {
  display: block;
  font-size: 10px;
  color: var(--text-light);
  padding: 2px 10px 0;
}
.sidebar-carry-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-secondary);
  transition: all 0.15s;
  min-height: 36px;
  position: relative;
}
.sidebar-carry-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.sidebar-carry-btn svg { flex-shrink: 0; opacity: 0.7; }
.sidebar-carry-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  margin-left: auto;
}
/* 顺延动态岛（手机端，类似灵动岛效果） */
.carry-island {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%) translateY(-100%);
  background: #1F2937; color: #fff; border-radius: 28px;
  padding: 0; z-index: 9998; max-width: 360px; width: calc(100% - 32px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  transition: transform 0.4s cubic-bezier(0.16,1,0.3,1), opacity 0.3s ease;
  opacity: 0; pointer-events: none;
}
.carry-island.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1; pointer-events: auto;
}
.carry-island-content {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; gap: 12px;
}
.carry-island-text { font-size: 14px; font-weight: 500; flex: 1; }
.carry-island-actions { display: flex; gap: 8px; flex-shrink: 0; }
.carry-island-btn {
  padding: 6px 16px; border-radius: 20px; border: none;
  font-size: 13px; font-family: inherit; cursor: pointer;
  font-weight: 500; transition: opacity 0.15s;
}
.carry-island-btn:hover { opacity: 0.85; }
.carry-island-btn.cancel { background: rgba(255,255,255,0.15); color: #fff; }
.carry-island-btn.primary { background: var(--primary); color: #fff; }
.carry-island-notch {
  width: 40px; height: 4px; background: rgba(255,255,255,0.3); border-radius: 4px;
  margin: 0 auto 6px; 
}

@media (min-width: 768px) {
  /* 桌面端不使用动态岛，用侧边栏顺延按钮代替 */
  .carry-island { display: none !important; }
}

/* 登录弹窗 */
.login-modal { max-width: 100%; }
.login-tabs { display: flex; gap: 0; }
.login-tab {
  padding: 6px 20px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.login-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-error {
  font-size: 12px;
  color: var(--danger);
  background: #FEE2E2;
  padding: 8px 12px;
  border-radius: 6px;
}

.sidebar-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-secondary);
  transition: all 0.15s;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.sidebar-action-btn:hover { background: var(--bg); color: var(--text); }
.sidebar-action-btn svg { flex-shrink: 0; opacity: 0.7; }

/* ===== 主内容区 ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 0 24px 100px;
  max-width: 900px;
  position: relative;
  margin-right: var(--ruler-w);
  min-height: 100vh;
}

/* ===== 顶部栏 ===== */
.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 28px 0 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
  gap: 16px;
}
.header-left { display: flex; flex-direction: column; gap: 6px; }
.header-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  transition: all 0.3s;
}
.header-date-row { display: flex; align-items: center; gap: 12px; }
.header-date {
  font-size: 13px;
  color: var(--text-secondary);
}
.header-weather-mobile {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2px 10px;
}
.hw-icon { font-size: 15px; }
.hw-temp { font-weight: 600; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.header-controls { display: flex; gap: 8px; }
.header-select {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  cursor: pointer;
  outline: none;
  font-family: inherit;
  min-height: 36px;
}
.header-select:focus { border-color: var(--primary); }

.icon-btn {
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px; min-height: 40px;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.icon-btn:active { background: var(--border); }

/* ===== 无限滚动列表 ===== */
.view-container { position: relative; }
.list-view-body { }
.list-loading { text-align: center; padding: 16px; font-size: 12px; color: var(--text-light); }

/* 日期分段 */
.day-section { margin-bottom: 32px; scroll-margin-top: 92px; }

/* 首次进入时今天区块的入场高亮动画 */
@keyframes todayFocusFlash {
  0%   { background: transparent; }
  20%  { background: color-mix(in srgb, var(--primary) 8%, transparent); }
  100% { background: transparent; }
}
.today-focus-flash {
  border-radius: 12px;
  animation: todayFocusFlash 1.2s ease-out forwards;
}

/* 任务跳转高亮动画 */
@keyframes taskJumpHighlight {
  0%   { background: transparent; box-shadow: none; }
  20%  { background: color-mix(in srgb, var(--primary) 10%, transparent); box-shadow: 0 0 0 2px var(--primary); }
  100% { background: transparent; box-shadow: none; }
}
.task-jump-highlight {
  border-radius: 10px;
  animation: taskJumpHighlight 1.2s ease-out forwards;
}
.day-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 14px;
  position: sticky;
  top: 72px;
  z-index: 50;
  background: var(--bg);
}
.day-header-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.day-header-label.today { color: var(--primary); font-size: 15px; }
.day-header-label.future { color: var(--text-light); }
.day-header-line { flex: 1; height: 1px; background: var(--border); }
.day-task-count {
  font-size: 11px;
  color: var(--text-light);
  background: var(--border);
  border-radius: 10px;
  padding: 1px 8px;
}
.daily-quote {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  opacity: 0.65;
  letter-spacing: 0.2px;
}
.daily-quote::before {
  content: '\201C';
  font-size: 16px;
  color: var(--primary);
  margin-right: 3px;
  vertical-align: -2px;
  opacity: 0.5;
}
.daily-quote::after {
  content: '\201D';
  font-size: 16px;
  color: var(--primary);
  margin-left: 3px;
  vertical-align: -2px;
  opacity: 0.5;
}

/* 任务列表 */
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow);
  transition: all 0.3s cubic-bezier(0.2,0,0,1), opacity 0.45s ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* 仅新创建的任务才播放入场动画（通过 data-new 属性标记） */
.task-item[data-new="true"] { animation: slideIn 0.3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.task-item:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.task-item:active { transform: scale(0.985); }

/* 时间标尺控制的动态状态 */
.task-item.not-yet { opacity: 0.12; transform: translateY(4px) scale(0.97); pointer-events: none; }
.task-item.emerging { opacity: 0.5; transform: translateY(2px) scale(0.98); }
.task-item.past { opacity: 1; transform: translateY(0) scale(1); }
.task-item.past.completed-dim { opacity: 0.5; }
.task-item.folded { order: 999; }

/* 任务行 */
.task-item-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; min-height: 40px; }

.task-item.completed { opacity: 0.5; background: #FAFAFA; }
.task-item.completed .task-title { text-decoration: line-through; color: var(--text-light); }

/* 用户主动跳过的任务：中性灰调，左侧斜线纹理 + 灰色删除线，清晰区分"不做了" */
.task-item.skipped {
  opacity: 0.5;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(148, 163, 184, 0.06) 4px,
    rgba(148, 163, 184, 0.06) 8px
  );
  border-left: 3px solid #94A3B8;
  box-shadow: none;
}
.task-item.skipped .task-title { text-decoration: line-through; text-decoration-color: #94A3B8; color: #94A3B8; }

/* carry 源任务：被系统顺延到明天的"留在昨天"的任务，暖黄左边框 + 黄色删除线，与 skipped 视觉区分 */
.task-item.carried-away { opacity: 0.42; background: transparent; border-left: 3px solid var(--warning); box-shadow: none; }
.task-item.carried-away .task-title { text-decoration: line-through; text-decoration-color: var(--warning); color: var(--warning); }

.task-item.dragging { opacity: 0.85; transform: scale(1.02) translateY(-2px); box-shadow: 0 12px 28px rgba(79,70,229,0.2); z-index: 50; border: 2px solid var(--primary-light); }
.task-item.drag-over { transform: translateY(4px); box-shadow: 0 0 0 2px var(--primary-light); }
.task-item.link-drag-over { box-shadow: 0 0 0 3px var(--primary-light); background: var(--primary-bg); }

/* ===== 展开面板 ===== */
.task-expand { max-height: 0; overflow: hidden; transition: max-height 0.35s cubic-bezier(0.16,1,0.3,1), opacity 0.25s ease, margin 0.25s ease; opacity: 0; margin-top: 0; }
.task-expand.active { max-height: 600px; opacity: 1; margin-top: 12px; overflow-y: auto; }
.task-expand-inner { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.expand-section {}
.expand-section-label { font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.expand-section-value { font-size: 13px; color: var(--text); line-height: 1.5; }
.expand-row { display: flex; gap: 16px; flex-wrap: wrap; }
.expand-actions { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; flex-wrap: wrap; }
.expand-action-btn {
  font-size: 12px; padding: 5px 12px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--white); color: var(--text-secondary); cursor: pointer;
  transition: all 0.15s; display: flex; align-items: center; gap: 4px;
  min-height: 36px; -webkit-tap-highlight-color: transparent;
}
.expand-action-btn:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.expand-action-btn:active { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }
.expand-action-btn.danger:hover { background: #FEE2E2; color: var(--danger); border-color: var(--danger); }

/* 子任务 */
.subtask-list { display: flex; flex-direction: column; gap: 0; }
.subtask-item { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 0; border-radius: 6px; cursor: pointer; font-size: 13px; margin-left: 8px; min-height: 40px; }
.subtask-item:hover { background: var(--bg); }
.subtask-item.done { opacity: 0.45; }
.subtask-item.done .subtask-title { text-decoration: line-through; color: var(--text-light); }
.subtask-indent-line { flex-shrink: 0; width: 16px; display: flex; align-items: center; justify-content: flex-end; position: relative; }
.subtask-indent-line::before { content: ''; position: absolute; left: 6px; top: -50%; bottom: 50%; border-left: 1.5px solid var(--border); }
.subtask-indent-line::after { content: ''; position: absolute; left: 6px; top: 50%; width: 8px; border-top: 1.5px solid var(--border); }
.subtask-item:last-of-type .subtask-indent-line::before { bottom: 50%; }
.subtask-title { flex: 1; min-width: 0; color: var(--text); word-break: break-word; }
.subtask-time { font-size: 10px; color: var(--text-light); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.subtask-time.done-time { color: var(--success); font-weight: 500; }
.subtask-checkbox { position: relative; width: 18px; height: 18px; flex-shrink: 0; }
.subtask-checkbox input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
.subtask-checkbox .checkmark { position: absolute; top: 0; left: 0; width: 18px; height: 18px; border: 1.5px solid var(--border); border-radius: 4px; transition: all 0.2s; }
.subtask-checkbox input:checked + .checkmark { background: var(--success); border-color: var(--success); }
.subtask-checkbox input:checked + .checkmark::after { content: ''; position: absolute; left: 5px; top: 1px; width: 5px; height: 9px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.subtask-add { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; font-size: 12px; color: var(--text-light); cursor: pointer; border: 1px dashed var(--border); margin-top: 4px; margin-left: 8px; min-height: 36px; }
.subtask-add:hover { border-color: var(--primary-light); color: var(--primary); }
.subtask-add input { flex: 1; border: none; outline: none; font-size: 13px; font-family: inherit; color: var(--text); background: transparent; }

/* 关联任务点击点 */
.link-dot {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: all 0.2s;
  z-index: 5;
}
.link-dot::before { content: ''; position: absolute; left: -8px; right: -8px; top: -8px; bottom: -8px; }
.link-dot:hover, .link-dot.active { background: var(--primary); transform: translateY(-50%) scale(1.4); box-shadow: 0 0 8px rgba(79,70,229,0.5); }
.link-dot.connected { background: var(--primary-light); }

/* 删除按钮固定在行尾，与关联点保持间距 */
.task-delete-btn {
  background: transparent; border: none; padding: 6px; color: var(--text-light); cursor: pointer; border-radius: 50%;
  transition: all 0.2s; flex-shrink: 0; min-width: 32px; min-height: 32px;
  display: flex; align-items: center; justify-content: center; opacity: 0;
  margin-right: 24px; /* 给 link-dot 留出空间 */
}
.task-item:hover .task-delete-btn { opacity: 1; }
.task-delete-btn:hover { color: var(--danger); background: #FEE2E2; }

/* ===== 快速输入行 ===== */
.inline-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: text;
  margin-top: 8px;
  border: 1.5px dashed var(--border);
  min-height: 48px;
  position: sticky;
  bottom: 16px;
  z-index: 40;
}
.inline-input-row:hover { box-shadow: var(--shadow-lg); border-color: var(--primary-light); }
.inline-input-icon { font-size: 18px; color: var(--text-light); font-weight: 300; flex-shrink: 0; }
.inline-input-placeholder { color: var(--text-light); font-size: 14px; flex: 1; }
.inline-input-field { flex: 1; border: none; outline: none; font-size: 16px; font-family: inherit; color: var(--text); background: transparent; }

/* ===== 时间标尺（右侧竖条） ===== */
.ruler-trigger {
  position: fixed;
  right: 0; top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 160px;
  z-index: 150;
  cursor: pointer;
  opacity: 0.3;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.ruler-trigger::before { content: ''; position: absolute; left: -20px; right: -6px; top: -10px; bottom: -10px; }
.ruler-trigger:hover, .ruler-trigger.active { opacity: 1; }
.ruler-trigger:hover::after, .ruler-trigger.active::after {
  content: '';
  position: absolute;
  right: 2px; top: 0; bottom: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--primary-light);
}

.ruler-bar {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: var(--ruler-w);
  z-index: 149;
  pointer-events: none;
  opacity: 0;
  transform: translateX(16px);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-left: 1px solid var(--border);
  box-shadow: -2px 0 12px rgba(0,0,0,0.06);
}
.ruler-bar.visible { opacity: 1; transform: translateX(0); pointer-events: auto; }

.ruler-bar-track {
  flex: 1;
  position: relative;
  cursor: pointer;
  margin: 72px 14px 24px 14px;
}
.ruler-bar-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: var(--border);
  transform: translateX(-50%);
}
.ruler-bar-handle {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  cursor: grab;
}
.ruler-bar-handle:active { cursor: grabbing; }
.ruler-handle-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.15), 0 0 12px rgba(79,70,229,0.3);
  transition: transform 0.15s;
}
.ruler-bar-handle:hover .ruler-handle-dot { transform: scale(1.2); }
.ruler-handle-time {
  position: absolute;
  right: 24px;
  top: -6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ruler-bar-labels {
  position: absolute;
  left: 0; right: 0;
  top: 72px; bottom: 24px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0 14px;
}
.ruler-bar-label {
  font-size: 9px;
  color: var(--text-light);
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ===== 时间轴标记点 ===== */
.ruler-task-dot {
  position: absolute;
  left: 50%;
  width: 5px; height: 5px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: auto;
  cursor: pointer;
  transition: all 0.2s;
}
.ruler-task-dot:hover { transform: translate(-50%, -50%) scale(1.6); }
.ruler-task-dot.created { background: var(--primary-light); }
.ruler-task-dot.done { background: var(--success); }
.ruler-task-dot.skipped { background: var(--warning); }

/* ===== 周视图 ===== */
.week-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 16px;
}
.week-nav-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--white);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.week-nav-btn:hover { border-color: var(--primary); color: var(--primary); }
.week-range { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; text-align: center; }

/* 关联线开关 — iOS 风格绿色拨动开关 */
.week-link-switch {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 12px; color: var(--text-secondary); user-select: none;
}
.week-link-switch-label { white-space: nowrap; }
.week-link-switch-track {
  position: relative; width: 40px; height: 22px;
  background: var(--border); border-radius: 11px;
  transition: background 0.25s ease; flex-shrink: 0;
}
.week-link-switch-track input {
  position: absolute; opacity: 0; width: 100%; height: 100%;
  cursor: pointer; z-index: 1; margin: 0;
}
.week-link-switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.25s ease;
}
.week-link-switch-track input:checked ~ .week-link-switch-thumb {
  transform: translateX(18px);
}
.week-link-switch-track:has(input:checked) {
  background: var(--success);
}

/* 周与周之间的分割线 */
.week-separator {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border) 20%, var(--border) 80%, transparent);
  margin: 8px 0;
}

/* 日期间隔 "..." 占位（超出默认一周范围时显示） */
.date-gap-placeholder {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; margin: 4px 0;
  border-radius: var(--radius);
  background: var(--white);
  border: 1.5px dashed var(--border);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-light);
  font-size: 13px;
}
.date-gap-placeholder:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  background: var(--primary-bg);
}
.gap-dots { font-size: 18px; letter-spacing: 4px; }
.gap-hint { font-size: 12px; opacity: 0.7; }

.week-grid-wrap { overflow-x: auto; overflow-y: visible; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.week-grid {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  min-width: 700px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
  touch-action: pan-x pan-y pinch-zoom;
}
.week-hour-cell {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-light);
  text-align: right;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  font-weight: 500;
}
.week-header-cell {
  padding: 10px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}
.week-header-cell.today { color: var(--primary); background: var(--primary-bg); }
.week-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 48px;
  position: relative;
  padding: 1px 2px;
  transition: background 0.15s;
}
.week-cell:nth-child(8n+1) { border-right: none; }
.week-task-chip {
  position: relative;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  margin-bottom: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}
.week-task-chip:hover { transform: scale(1.03); z-index: 3; box-shadow: var(--shadow); }
.week-task-chip.done { opacity: 0.5; text-decoration: line-through; }
/* 紧急度色阶：浅 → 深 */
.week-task-chip.urg-low { background: #F0F9FF; border-left-color: #BAE6FD; color: #0284C7; }
.week-task-chip.urg-med { background: #EFF6FF; border-left-color: #93C5FD; color: #2563EB; }
.week-task-chip.urg-high { background: #EEF2FF; border-left-color: #818CF8; color: #4F46E5; }
.week-task-chip.urg-critical { background: #FEE2E2; border-left-color: #FCA5A5; color: #DC2626; }

/* 顺延任务 chip（有 carrySourceId，在顺延后日期列显示）：带暖黄左边框 + 小图标 */
.week-task-chip.carry-chip {
  border-left-color: var(--warning);
  background: #FFFBEB;
  color: #92400E;
}
.week-task-chip.carry-chip .carry-icon {
  font-size: 9px;
  margin-right: 3px;
  opacity: 0.8;
}

/* 顺延幽灵 chip（在原始日期列显示"已顺延出去"的占位）：半透明虚线边框 */
.week-task-chip.carry-ghost {
  opacity: 0.45;
  background: transparent;
  border: 1px dashed var(--warning);
  border-left: 2px dashed var(--warning);
  color: #B45309;
  font-style: italic;
  position: relative;
}
.week-task-chip.carry-ghost::before {
  content: '▸';
  font-size: 9px;
  margin-right: 3px;
  opacity: 0.7;
}
.week-task-chip.carry-ghost:hover {
  opacity: 0.75;
}

/* 周视图关联线（canvas overlay） */
.week-links-canvas {
  position: absolute; top: 0; left: 0;
  pointer-events: none;
  z-index: 1;
}

/* ===== 右键菜单（移动端底部弹出桌面端跟随鼠标） ===== */
.context-menu {
  position: fixed;
  z-index: 999;
  background: var(--white);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.18);
  padding: 8px 0;
  display: none;
  left: 0; right: 0; bottom: 0;
  animation: ctxUp 0.2s ease;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
@keyframes ctxUp { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: translateY(0); } }
.context-menu.active { display: block; }
.ctx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}
.ctx-item:active { background: var(--primary-bg); color: var(--primary); }
.ctx-item-skip { color: var(--warning); }
.ctx-item-danger { color: var(--danger); }
.context-menu-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.25); z-index: 998; display: none; }
.context-menu-overlay.active { display: block; }

/* 桌面右键菜单 */
@media (min-width: 768px) {
  .context-menu {
    bottom: auto; left: auto; right: auto;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
    padding: 6px 0;
    min-width: 170px;
    padding-bottom: 6px;
    animation: ctxIn 0.12s ease;
  }
  @keyframes ctxIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
  .ctx-item { padding: 9px 16px; font-size: 13px; min-height: 0; gap: 8px; }
  .ctx-item:hover { background: var(--primary-bg); color: var(--primary); }
  .ctx-item-skip:hover { background: #FEF3C7; color: #B45309; }
  .ctx-item-danger:hover { background: #FEE2E2; color: var(--danger); }
  .context-menu-overlay { display: none !important; }
}

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.45);
  z-index: 300;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white);
  border-radius: 16px 16px 0 0;
  width: 100%; max-width: 100%;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
  animation: modalUp 0.3s ease;
  max-height: 85vh;
  display: flex; flex-direction: column;
}
@keyframes modalUp { from { opacity: 0; transform: translateY(60px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.close-btn { background: transparent; border: none; font-size: 26px; color: var(--text-secondary); cursor: pointer; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: all 0.2s; -webkit-tap-highlight-color: transparent; }
.close-btn:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); flex-shrink: 0; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 5px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 16px; color: var(--text);
  outline: none; transition: border-color 0.2s; font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

/* 分类选择器 */
.category-selector { display: flex; flex-wrap: wrap; gap: 6px; }
.category-chip { display: flex; align-items: center; padding: 8px 14px; border: 1.5px solid var(--border); border-radius: 20px; cursor: pointer; font-size: 13px; transition: all 0.2s; user-select: none; min-height: 40px; -webkit-tap-highlight-color: transparent; }
.category-chip input { display: none; }
.category-chip span { pointer-events: none; }
.cat-urgent-important input:checked + span, .category-chip.cat-urgent-important.selected { color: #EF4444; font-weight: 500; }
.category-chip.cat-urgent-important.selected { background: #FEE2E2; border-color: #EF4444; }
.cat-important input:checked + span, .category-chip.cat-important.selected { color: #4F46E5; font-weight: 500; }
.category-chip.cat-important.selected { background: var(--primary-bg); border-color: #4F46E5; }
.cat-urgent input:checked + span, .category-chip.cat-urgent.selected { color: #B45309; font-weight: 500; }
.category-chip.cat-urgent.selected { background: #FEF3C7; border-color: #F59E0B; }
.cat-low input:checked + span, .category-chip.cat-low.selected { color: #4B5563; font-weight: 500; }
.category-chip.cat-low.selected { background: #F3F4F6; border-color: #9CA3AF; }

.task-category-tag { display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 500; margin-top: 4px; line-height: 1.6; }
.tag-urgent-important { background: #FEE2E2; color: #EF4444; }
.tag-important { background: var(--primary-bg); color: #4F46E5; }
.tag-urgent { background: #FEF3C7; color: #B45309; }
.tag-low { background: #F3F4F6; color: #4B5563; }

/* ===== 按钮 ===== */
.btn { padding: 10px 22px; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; min-height: 44px; -webkit-tap-highlight-color: transparent; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #4338CA; }
.btn-secondary { background: var(--border); color: var(--text-secondary); }
.btn-secondary:hover { background: #D1D5DB; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); border-radius: var(--radius-sm); padding: 10px 22px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; min-height: 44px; }
.btn-danger-outline:hover { background: #FEE2E2; }
.btn-primary-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); border-radius: var(--radius-sm); padding: 10px 22px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; min-height: 44px; }
.btn-primary-outline:hover { background: var(--primary-bg); }

/* ===== 复选框 ===== */
.task-checkbox { position: relative; width: 22px; height: 22px; flex-shrink: 0; margin-top: 1px; }
.task-checkbox input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
.task-checkbox .checkmark { position: absolute; top: 0; left: 0; width: 22px; height: 22px; border: 2px solid var(--border); border-radius: 50%; transition: all 0.2s; }
.task-checkbox input:checked + .checkmark { background: var(--success); border-color: var(--success); }
.task-checkbox input:checked + .checkmark::after { content: ''; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.task-content { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 500; line-height: 1.4; word-break: break-word; }
.task-meta { font-size: 11px; color: var(--text-light); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.task-meta-item { display: flex; align-items: center; gap: 3px; }
.task-meta-item.overdue { color: var(--danger); font-weight: 500; }
.task-carryover { font-size: 10px; color: var(--warning); margin-top: 2px; }
.task-stale-done-tag { font-size: 10px; color: var(--success); margin-top: 2px; }

/* task-delete-btn 样式已移到关联按钮附近，统一管理间距 */

.link-count-badge { font-size: 10px; padding: 1px 6px; border-radius: 10px; background: var(--primary-bg); color: var(--primary-light); margin-left: 4px; font-weight: 500; }

.task-time-row { display: flex; justify-content: flex-end; margin-top: 5px; }
.task-time-badge { font-size: 10px; line-height: 1.4; padding: 1px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.task-time-badge.created { color: var(--text-light); }
.task-time-badge.updated { color: var(--primary-light); background: var(--primary-bg); }
.task-time-badge.done { color: var(--success); background: #D1FAE5; }
.task-time-badge.skipped { color: var(--warning); background: #FEF3C7; }
.task-time-badge.carried { color: var(--warning); background: #FEF3C7; font-weight: 500; }
.task-completion-note { font-size: 11px; color: var(--text-secondary); margin-top: 3px; font-style: italic; line-height: 1.4; }

.empty-state { text-align: center; padding: 32px 20px; color: var(--text-light); }
.empty-state p { margin-top: 10px; font-size: 13px; }

/* ===== AI 面板 + 设置面板（侧滑） ===== */
.panel-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 250;
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.panel-overlay::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(0,0,0,0.35);
}
.panel-overlay.active {
  opacity: 1; pointer-events: auto;
}

/* 侧滑子面板 */
.ai-panel, .settings-panel {
  position: absolute; right: 0; top: 0; height: 100%; width: 100%; max-width: 400px;
  background: var(--white); box-shadow: -4px 0 20px rgba(0,0,0,0.12);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  transform: translateX(100%); transition: transform 0.3s ease;
}
.ai-panel { max-width: 100%; }
.panel-overlay.active .ai-panel,
.panel-overlay.active .settings-panel {
  transform: translateX(0);
}
@media (max-width: 480px) {
  .settings-panel { max-width: 100%; }
}
@keyframes slideRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.ai-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.ai-header h3 { font-size: 15px; font-weight: 600; }
.ai-header-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ai-quick-btn { font-size: 11px !important; padding: 4px 10px !important; border-radius: 6px !important; min-width: auto !important; min-height: 32px !important; }
.ai-messages { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.ai-welcome { font-size: 13px; line-height: 1.7; color: var(--text-secondary); }
.ai-msg { max-width: 90%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.6; animation: fadeIn 0.3s ease; word-break: break-word; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.ai-msg-user { align-self: flex-end; background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.ai-msg-assistant { align-self: flex-start; background: #F3F4F6; color: var(--text); border-bottom-left-radius: 4px; }
/* AI 回复中的 Markdown 渲染样式 */
.ai-msg-assistant h1 { font-size: 1.25em; font-weight: 700; margin: 0.6em 0 0.3em; line-height: 1.3; }
.ai-msg-assistant h2 { font-size: 1.1em; font-weight: 700; margin: 0.5em 0 0.2em; line-height: 1.3; }
.ai-msg-assistant h3 { font-size: 1em; font-weight: 700; margin: 0.4em 0 0.2em; line-height: 1.3; }
.ai-msg-assistant p  { margin: 0.3em 0; }
.ai-msg-assistant strong { font-weight: 700; color: var(--text); }
.ai-msg-assistant em { font-style: italic; }
.ai-msg-assistant code { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 0.9em; background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 3px; word-break: break-all; }
.ai-msg-assistant pre { background: #1E1E2E; color: #CDD6F4; border-radius: 8px; padding: 12px 14px; margin: 8px 0; overflow-x: auto; font-size: 0.85em; line-height: 1.5; }
.ai-msg-assistant pre code { background: transparent; padding: 0; font-size: inherit; border-radius: 0; color: inherit; word-break: normal; }
.ai-msg-assistant ul, .ai-msg-assistant ol { margin: 0.3em 0; padding-left: 1.3em; }
.ai-msg-assistant li { margin: 0.15em 0; }
.ai-msg-assistant a { color: var(--primary); text-decoration: underline; }
.ai-msg-assistant a:hover { color: #4338CA; }
.ai-msg-assistant blockquote { border-left: 3px solid var(--primary); padding-left: 10px; margin: 0.4em 0; color: var(--text-secondary); }
.ai-msg-assistant hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.ai-msg-error { align-self: flex-start; background: #FEE2E2; color: var(--danger); border-bottom-left-radius: 4px; }
.ai-typing { align-self: flex-start; background: #F3F4F6; padding: 10px 14px; border-radius: 12px; border-bottom-left-radius: 4px; }
.ai-typing-dots { display: flex; gap: 4px; }
.ai-typing-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--text-light); animation: typingBounce 1.2s infinite; }
.ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* AI 动作指令卡片 */
.ai-action-cards { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.ai-action-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card, #fff); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; transition: opacity 0.2s, border-color 0.2s;
  cursor: pointer;
}
.ai-action-card:hover { border-color: var(--primary-light, #C7D2FE); }
.ai-action-card.resolved { opacity: 0.55; pointer-events: none; }
.ai-action-card.executing { pointer-events: none; }
.ai-action-card-danger:hover { border-color: var(--danger); }
.ai-action-check-box {
  flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  color: var(--border); transition: color 0.2s, transform 0.2s;
}
.ai-action-card:hover .ai-action-check-box { color: var(--primary); }
.ai-action-check-box.checked { color: var(--success, #22c55e); }
.ai-action-check-box .ai-action-check-mark {
  stroke-dasharray: 30; stroke-dashoffset: 30; transition: stroke-dashoffset 0.25s ease;
}
.ai-action-card:hover .ai-action-check-mark { stroke-dashoffset: 0; }
.ai-action-check-box.checked .ai-action-check-mark { stroke-dashoffset: 0; }
.ai-action-card-body { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ai-action-label { font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 3px; }
.ai-action-desc { font-size: 13px; line-height: 1.4; overflow: hidden; }
.ai-action-desc strong { font-weight: 600; }
.ai-action-desc small { font-size: 11px; color: var(--text-secondary); }
.ai-action-cat { font-size: 10px; background: var(--primary-bg, #EEF2FF); color: var(--primary); padding: 1px 5px; border-radius: 4px; }
.ai-action-card-btns { display: flex; gap: 6px; flex-shrink: 0; }
.ai-action-btn {
  padding: 5px 14px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.ai-action-btn.confirm { background: var(--primary); color: white; border-color: var(--primary); }
.ai-action-btn.confirm:hover { opacity: 0.85; }
.ai-action-btn.cancel { background: transparent; color: var(--text-secondary); }
.ai-action-btn.cancel:hover { background: var(--bg-hover, #f5f5f5); }
.ai-action-result { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 3px; }
.ai-action-result.success { color: var(--success); }
.ai-action-result.cancelled { color: var(--text-light); }
.ai-action-result.error { color: var(--danger); }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }
.ai-input-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); flex-shrink: 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.ai-input-bar input { flex: 1; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 20px; font-size: 16px; outline: none; transition: border-color 0.2s; min-height: 40px; }
.ai-input-bar input:focus { border-color: var(--primary); }
.ai-send-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: white; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; -webkit-tap-highlight-color: transparent; }
.ai-send-btn:hover { background: #4338CA; }
.ai-mic-btn { width: 40px; height: 40px; border-radius: 50%; background: transparent; color: var(--text-secondary); border: 1.5px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; -webkit-tap-highlight-color: transparent; }
.ai-mic-btn:hover { background: var(--bg-hover, #f5f5f5); color: var(--text); }
.ai-mic-btn.recording { background: var(--danger); color: white; border-color: var(--danger); animation: micPulse 1.5s infinite; }
.ai-mic-btn.unsupported { opacity: 0.3; cursor: not-allowed; }
@keyframes micPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* ===== 设置面板 ===== */
/* ===== 设置面板（侧滑） ===== */
.settings-panel {
  position: absolute; right: 0; top: 0; width: 100%; max-width: 400px; height: 100%;
  background: var(--white); box-shadow: -4px 0 20px rgba(0,0,0,0.12);
  display: flex; flex-direction: column; animation: slideRight 0.3s ease;
  padding-top: env(safe-area-inset-top);
}
.settings-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.settings-panel-header h3 { font-size: 16px; font-weight: 600; }
.settings-panel-scroll {
  flex: 1; overflow-y: auto; padding: 6px 0 16px; -webkit-overflow-scrolling: touch;
}
.settings-panel-footer {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0;
}
@media (max-width: 480px) {
  .settings-panel { max-width: 100%; }
}
.settings-scroll { max-height: 60vh; overflow-y: auto; padding: 0 4px; -webkit-overflow-scrolling: touch; }
.settings-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }
.settings-group { margin: 16px 20px; padding: 16px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); }
.settings-group-danger { border-color: #FCA5A5; background: #FFF5F5; }
.settings-group-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
.settings-group-danger .settings-group-title { color: #DC2626; border-bottom-color: #FECACA; }
.setting-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; gap: 12px; }
.setting-item + .setting-item { border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.setting-item:last-child { padding-bottom: 0; }
.setting-label { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.setting-name { font-size: 14px; font-weight: 500; color: var(--text); }
.setting-desc { font-size: 11px; color: var(--text-light); line-height: 1.3; }
.setting-select { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text); outline: none; min-width: 130px; flex-shrink: 0; background: white; cursor: pointer; }
.setting-select:focus { border-color: var(--primary); }
.setting-item.setting-vertical { flex-direction: column; align-items: stretch; gap: 6px; }
.setting-field-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.setting-field-hint { font-size: 11px; color: var(--text-light); line-height: 1.4; margin-top: 2px; }
.setting-input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--text); outline: none; transition: border-color 0.2s, box-shadow 0.2s; font-family: 'SF Mono', 'Fira Code', Consolas, monospace; background: white; }
.setting-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent); }
.toggle { position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--border); border-radius: 28px; transition: 0.3s; }
.toggle-slider::before { content: ''; position: absolute; height: 22px; width: 22px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ===== 存储设置 ===== */
.storage-status { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; font-size: 12px; margin-bottom: 10px; }
.storage-status-local { background: #FEF3C7; color: #92400E; }
.storage-status-file { background: #D1FAE5; color: #065F46; }
.storage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.storage-status-local .storage-dot { background: #F59E0B; }
.storage-status-file .storage-dot { background: #10B981; }
.storage-path { font-weight: 600; font-family: monospace; font-size: 11px; }
.storage-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.storage-actions .btn { font-size: 12px; padding: 8px 12px; }
.storage-hint { font-size: 11px; color: var(--text-light); margin: 8px 0 0; text-align: center; line-height: 1.4; }

/* ===== 日志 ===== */
.task-log-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; max-height: 160px; overflow-y: auto; }
.task-log-item { display: flex; align-items: center; gap: 6px; font-size: 11px; padding: 4px 8px; border-radius: 6px; background: var(--bg); }
.log-type { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 10px; white-space: nowrap; }
.log-type-create { background: var(--primary-bg); color: var(--primary); }
.log-type-update { background: #FEF3C7; color: #B45309; }
.log-type-complete { background: #D1FAE5; color: var(--success); }
.log-type-skip { background: #FEF3C7; color: var(--warning); }
.log-type-uncomplete { background: #F3F4F6; color: var(--text-secondary); }
.log-time { color: var(--text-light); font-size: 11px; white-space: nowrap; }

/* 关联弹窗 */
.link-picker-modal { max-width: 100%; }
.link-picker-list { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow-y: auto; }
.link-picker-task { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; transition: all 0.15s; min-height: 44px; }
.link-picker-task:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.link-picker-task.selected { border-color: var(--primary); background: var(--primary-bg); }

/* ===== 画线模式光标 ===== */
.link-drawing-cursor { cursor: crosshair; }
.link-line-preview {
  position: fixed;
  pointer-events: none;
  z-index: 900;
}
.link-line-preview svg { overflow: visible; }

/* ====== 手机底部导航 — 苹果风格 ====== */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 200;
  /* 毛玻璃效果 */
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid rgba(0, 0, 0, 0.1);
  padding: 4px 0 max(4px, env(safe-area-inset-bottom));
  justify-content: space-around;
  align-items: flex-start;
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: transparent; border: none; cursor: pointer;
  padding: 6px 0 2px; min-width: 56px;
  font-family: inherit; color: #8E8E93;
  transition: color 0.2s; -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-icon { width: 24px; height: 24px; flex-shrink: 0; }
.bottom-nav-label { font-size: 10px; font-weight: 500; letter-spacing: -0.1px; }
/* 中间加号按钮 */
.bottom-nav-add-btn {
  justify-content: center;
  width: 44px; height: 44px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  padding: 0;
  min-width: unset;
}
.bottom-nav-add-btn:active {
  transform: scale(0.92);
  box-shadow: 0 1px 6px rgba(79, 70, 229, 0.25);
}
.bottom-nav-add-btn svg { width: 22px; height: 22px; }

/* ====== 响应式 ====== */

/* 平板以下 (< 1024px) — 隐藏侧边栏，显示移动端布局 */
@media (max-width: 1023px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; margin-right: 0; padding: 0 16px 110px; max-width: 100%; }
  .header { padding: 14px 0 10px; }
  .header-title { font-size: 22px; }
  .header-controls { display: none; }
  .header-right { gap: 8px; }

  /* 移动端显示底部导航 */
  .bottom-nav { display: flex; }

  .ruler-trigger { right: 4px; width: 6px; height: 120px; }
  .ruler-bar { width: 36px; }
  .ruler-bar-track { margin: 60px 10px 20px 10px; }
  .ruler-handle-time { right: 22px; font-size: 10px; }

  .inline-input-row { bottom: 8px; }

  .week-grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .week-grid { min-width: 560px; font-size: 10px; }
  .week-hour-cell { padding: 4px 6px; font-size: 10px; }
  .week-header-cell { padding: 8px 4px; font-size: 11px; }
  .week-cell { min-height: 36px; }
  .week-task-chip { padding: 2px 6px; font-size: 10px; min-height: 24px; }

  /* bottom bar for mobile view switching */
  .header-controls { display: flex; }
  .header-select { font-size: 12px; padding: 5px 8px; min-height: 32px; }
}

/* 手机 (< 640px) */
@media (max-width: 639px) {
  .main-content { padding: 0 12px 120px; }
  .header { padding: 12px 0 8px; flex-direction: column; gap: 8px; }
  .header-left { width: 100%; }
  .header-right { width: 100%; justify-content: space-between; }
  .header-title { font-size: 20px; }
  .day-header { top: 96px; }
  .day-header-label { font-size: 13px; }
  .task-item { padding: 12px 14px 10px; }
  .task-title { font-size: 14px; }
  .ruler-bar-track { margin: 56px 8px 16px 8px; }

  /* 弹窗桌面居中改为移动端底部弹出 */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-width: 100%; }
  @keyframes modalUp { from { opacity: 0; transform: translateY(60px); } to { opacity: 1; transform: translateY(0); } }
}

/* 桌面端 (≥ 1024px) */
@media (min-width: 1024px) {
  .header-weather-mobile { display: none; } /* 桌面端天气在侧边栏 */
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: var(--radius); max-width: 460px; box-shadow: var(--shadow-lg); animation: modalIn 0.25s ease; }
  @keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
  .modal-footer { padding-bottom: 16px; }
  .ai-panel { width: 420px; max-width: 90%; }
  .ai-header { padding: 16px 20px; }
  .ai-messages { padding: 16px 20px; }
  .ai-input-bar { padding: 12px 16px; }

  .form-group input, .form-group textarea { font-size: 14px; }
  .setting-input { font-size: 14px; }
  .inline-input-field { font-size: 15px; }
  .ai-input-bar input { font-size: 14px; }
}

/* 宽屏 (≥ 1280px) */
@media (min-width: 1280px) {
  .main-content { max-width: 960px; margin-right: var(--ruler-w); }
}

/* ===== Toast 通知系统 ===== */
.toast-notification {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: #1F2937; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 14px; z-index: 9999; opacity: 0; transition: all 0.3s ease;
  max-width: 90vw; white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  pointer-events: none;
}
.toast-notification.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-notification.hide { opacity: 0; transform: translateX(-50%) translateY(-20px); }

/* 手机端适配 */
@media (max-width: 480px) {
  .toast-notification { top: 12px; font-size: 13px; padding: 8px 16px; }
}

/* SVG 图标通用样式 */
.ic { vertical-align: middle; display: inline-block; flex-shrink: 0; }

/* 手机端隐藏任务行尾的删除按钮（点击展开详情后用底部按钮删除）
   同时调整关联点在手机端的间距，避免和时间行重叠 */
@media (max-width: 1023px) {
  .task-delete-btn { display: none; }
  .link-dot { right: 6px; }
  /* 关联点移走后让时间行有更多空间 */
  .task-time-row { margin-right: 24px; }
}

/* 极小屏 (< 360px) */
@media (max-width: 359px) {
  .header-title { font-size: 18px; }
  .header-controls { gap: 4px; }
  .header-select { font-size: 11px; padding: 4px 6px; }
}
