/* === AI 安排 v11 极简 === */
:root {
  --ai-purple: #7c3aed;
  --ai-purple-2: #a78bfa;
  --ai-purple-bg: #faf5ff;
  --ai-orange: #f97316;
  --ai-orange-bg: #fff7ed;
  --ai-green: #10b981;
  --ai-red: #ef4444;
  --ai-red-bg: #fef2f2;
  --ai-text: #1c1917;
  --ai-text-2: #57534e;
  --ai-text-3: #a8a29e;
  --ai-line: #e7e5e4;
  --ai-line-2: #d6d3d1;
  --ai-bg: #fafaf9;
}

/* 浮气泡 (右下) */
#ai-bubble {
  position: fixed; bottom: 24px; right: 24px;
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: white; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4), 0 2px 6px rgba(0,0,0,0.1);
  z-index: 9980; user-select: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
#ai-bubble:hover { transform: scale(1.08); }
#ai-bubble .b {
  position: absolute; top: -4px; right: -4px;
  background: var(--ai-orange); color: white;
  font-size: 10px; font-weight: 600;
  min-width: 18px; height: 18px; border-radius: 100px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
  border: 2px solid var(--ai-bg);
}
#ai-bubble .b.h { display: none; }

/* 浮窗 */
#ai-panel {
  position: fixed; bottom: 96px; right: 24px;
  width: 380px;
  background: white; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0,0,0,0.04);
  z-index: 9990; display: none; flex-direction: column;
  overflow: hidden;
  animation: ai-up 0.18s ease-out;
}
#ai-panel.open { display: flex; }
@keyframes ai-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

#ai-panel header {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: white; padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
  cursor: grab;
}
#ai-panel header.grabbing { cursor: grabbing; }
#ai-panel header .ai-pic {
  width: 26px; height: 26px; background: rgba(255,255,255,0.2);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
#ai-panel header .t { flex: 1; }
#ai-panel header .t .title { font-size: 13px; font-weight: 600; line-height: 1.2; }
#ai-panel header .t .sub { font-size: 10.5px; opacity: 0.85; margin-top: 1px; }
#ai-panel header .range-chip {
  background: rgba(255,255,255,0.18); color: white;
  padding: 3px 8px; border-radius: 4px; font-size: 11px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.25);
  display: inline-flex; align-items: center; gap: 3px;
  user-select: none; position: relative;
}
#ai-panel header .range-chip:hover { background: rgba(255,255,255,0.28); }
#ai-panel header .range-chip::after { content: '▾'; font-size: 9px; opacity: 0.8; }
#ai-panel header .x {
  background: transparent; border: none; color: white;
  padding: 0 6px; cursor: pointer; font-size: 18px; opacity: 0.85; line-height: 1;
}
#ai-panel header .x:hover { opacity: 1; }

#ai-panel .body { padding: 12px; }
#ai-panel .input-row { display: flex; gap: 6px; align-items: flex-end; }
#ai-panel textarea {
  flex: 1; border: 1.5px solid var(--ai-line-2); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
  resize: none; min-height: 44px; max-height: 120px; line-height: 1.5;
}
#ai-panel textarea:focus { outline: none; border-color: var(--ai-purple); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1); }
#ai-panel .send {
  background: linear-gradient(135deg, #7c3aed, #6d28d9); color: white; border: none;
  width: 44px; height: 44px; border-radius: 8px; font-size: 16px;
  cursor: pointer; font-family: inherit; font-weight: 600;
  flex-shrink: 0;
}
#ai-panel .send:hover { background: linear-gradient(135deg, #6d28d9, #5b21b6); }
#ai-panel .send:disabled { background: #d6d3d1; cursor: not-allowed; }
#ai-panel .foot {
  padding: 0 12px 10px; font-size: 10.5px; color: var(--ai-text-3);
}
#ai-panel .foot b { color: var(--ai-text-2); }

/* 蒙版 */
#ai-mask {
  position: fixed; inset: 0; z-index: 9970;
  background: rgba(250, 250, 249, 0.55);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  display: none; align-items: center; justify-content: center;
}
#ai-mask.open { display: flex; }
#ai-mask .thinking {
  background: white; border-radius: 12px; padding: 14px 22px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  font-size: 13px; color: var(--ai-text);
}
#ai-mask .spin {
  width: 16px; height: 16px;
  border: 2.5px solid var(--ai-purple-bg);
  border-top-color: var(--ai-purple);
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* 时间段选择浮层 - position:fixed 脱离 panel overflow 裁剪 */
#ai-range-pop {
  position: fixed; z-index: 10000; display: none;
  background: white; border: 1px solid var(--ai-line); border-radius: 10px;
  padding: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  min-width: 240px;
  color: var(--ai-text);
}
#ai-range-pop.open { display: block; }
#ai-range-pop .title {
  font-size: 12px; font-weight: 600; margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
}
#ai-range-pop .title .x { color: var(--ai-text-3); cursor: pointer; }
#ai-range-pop .opt {
  padding: 6px 8px; border-radius: 5px; font-size: 12px; cursor: pointer;
}
#ai-range-pop .opt:hover { background: var(--ai-purple-bg); color: var(--ai-purple); }
#ai-range-pop .opt.active { background: var(--ai-purple); color: white; }
#ai-range-pop .opt small { color: var(--ai-text-3); margin-left: 4px; font-size: 10px; }
#ai-range-pop .opt.active small { color: rgba(255,255,255,0.7); }
#ai-range-pop .divider { height: 1px; background: var(--ai-line); margin: 4px 0; }
#ai-range-pop .custom {
  padding: 6px 8px; border-top: 1px solid var(--ai-line); margin-top: 4px;
}
#ai-range-pop .custom .row {
  display: flex; gap: 4px; align-items: center; padding: 3px 0;
}
#ai-range-pop .custom label {
  font-size: 10.5px; color: var(--ai-text-2); min-width: 36px;
}
#ai-range-pop .custom input {
  flex: 1; border: 1px solid var(--ai-line-2); border-radius: 4px;
  padding: 3px 6px; font-size: 11.5px; font-family: inherit;
}
#ai-range-pop .custom button {
  background: var(--ai-purple); color: white; border: none;
  border-radius: 4px; padding: 4px 8px; font-size: 11px; cursor: pointer;
  font-family: inherit; margin-top: 4px; width: 100%;
}

/* 通知 toast (成功 / 失败) */
#ai-toast {
  position: fixed; top: 60px; right: 20px;
  background: var(--ai-text); color: white;
  padding: 10px 14px; border-radius: 6px; font-size: 12.5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 9995; display: none; align-items: center; gap: 8px;
  max-width: 320px;
}
#ai-toast.open { display: flex; }
#ai-toast.ok { background: #065f46; }
#ai-toast.err { background: #7f1d1d; }
#ai-toast button {
  background: transparent; color: var(--ai-orange);
  border: none; font-weight: 600; cursor: pointer; font-size: 12.5px;
  font-family: inherit;
}
#ai-toast .x { background: transparent; color: white; opacity: 0.7; border: none; cursor: pointer; font-size: 14px; }

/* 响应式: 小屏 */
@media (max-width: 480px) {
  #ai-bubble { bottom: 16px; right: 16px; }
  #ai-panel { width: calc(100vw - 32px); right: 16px; bottom: 88px; }
}


/* 锁格菜单 (右键 cell) */
#lock-menu {
  position: fixed; z-index: 9990;
  background: white; border: 1px solid var(--ai-line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 4px; min-width: 160px;
  display: none;
  font-size: 12.5px;
}
#lock-menu.open { display: block; }
#lock-menu .item {
  padding: 6px 10px; border-radius: 5px; cursor: pointer; color: var(--ai-text);
  display: flex; align-items: center; gap: 6px;
}
#lock-menu .item:hover { background: var(--ai-purple-bg); color: var(--ai-purple); }
#lock-menu .item .ic { font-size: 14px; }
#lock-menu .item.danger { color: var(--ai-red); }
#lock-menu .item.danger:hover { background: var(--ai-red-bg); color: var(--ai-red); }
#lock-menu .divider { height: 1px; background: var(--ai-line); margin: 4px 0; }
#lock-menu .status {
  padding: 6px 10px; color: var(--ai-text-3); font-size: 10.5px;
}
.todo-cell.locked {
  position: relative;
  background: var(--ai-red-bg) !important;
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 8px,
    rgba(239, 68, 68, 0.08) 8px, rgba(239, 68, 68, 0.08) 16px
  ) !important;
}
.todo-cell.locked::after {
  z-index: 2;
  content: "🔒";
  position: absolute; top: 4px; left: 4px;
  width: 18px; height: 18px; line-height: 18px; text-align: center;
  background: white; border-radius: 50%;
  font-size: 11px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  pointer-events: none;
}


.todo-cell.important {
  position: relative;
  background: #fffbeb !important;
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 8px,
    rgba(245, 158, 11, 0.10) 8px, rgba(245, 158, 11, 0.10) 16px
  ) !important;
}
.todo-cell.important::after {
  z-index: 2;
  content: "★";
  position: absolute; top: 4px; left: 4px;
  width: 18px; height: 18px; line-height: 18px; text-align: center;
  color: #f59e0b;
  background: white; border-radius: 50%;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  pointer-events: none;
}

.todo-cell.busy {
  position: relative;
  background: #eff6ff !important;
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 8px,
    rgba(59, 130, 246, 0.08) 8px, rgba(59, 130, 246, 0.08) 16px
  ) !important;
}
.todo-cell.busy::after {
  z-index: 2;
  content: "💼";
  position: absolute; top: 4px; left: 4px;
  width: 18px; height: 18px; line-height: 18px; text-align: center;
  background: white; border-radius: 50%;
  font-size: 11px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  pointer-events: none;
}
