/* ========== 基础 ========== */
:root {
  --bg: #f3f5f9;
  --card-bg: #ffffff;
  --text: #1f2430;
  --text-light: #6b7280;
  --border: #e5e8ef;
  --primary: #4f6ef7;
  --primary-dark: #3d5ae0;
  --danger: #e5484d;
  --todo: #64748b;
  --doing: #4f6ef7;
  --blocked: #e5484d;
  --done: #22a06b;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .18);
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;  /* iOS 地址栏伸缩时高度更准确 */
  -webkit-tap-highlight-color: transparent;  /* 去掉 iOS 点击灰色闪框 */
}

.hidden { display: none !important; }

/* ========== 顶部栏 ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo { font-size: 20px; font-weight: 700; letter-spacing: .5px; }

.actions { display: flex; align-items: center; gap: 12px; }

.select-box {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  outline: none;
}
.select-box:focus { border-color: var(--primary); }

/* ========== 按钮 ========== */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost { background: transparent; color: var(--text-light); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f1f3f7; }

.btn-danger { background: #fdecec; color: var(--danger); }
.btn-danger:hover { background: #fbdcdc; }

/* ========== 统计条 ========== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 20px 28px 4px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.stat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-total { background: var(--text-light); }
.dot-todo { background: var(--todo); }
.dot-doing { background: var(--doing); }
.dot-blocked { background: var(--blocked); }
.dot-done { background: var(--done); }
.dot-due { background: #f59e0b; }
.dot-overdue { background: #7c3aed; }

.stat-info { display: flex; flex-direction: column; }
.stat-label { font-size: 12px; color: var(--text-light); }
.stat-num { font-size: 20px; font-weight: 700; line-height: 1.2; }

/* ========== 看板 ========== */
.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 16px 28px 32px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(2, 1fr); }
}

.column {
  background: #eceff4;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  min-height: 320px;
}

.column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
}

.column-count {
  background: rgba(0, 0, 0, .08);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 600;
}

.column-body {
  padding: 4px 10px 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background .15s;
  border-radius: 0 0 var(--radius) var(--radius);
}

.column-body.drag-over { background: rgba(79, 110, 247, .08); }

.empty-tip {
  text-align: center;
  color: #9aa2b1;
  font-size: 13px;
  padding: 28px 0;
  border: 1.5px dashed #cdd3de;
  border-radius: 8px;
}

/* ========== 任务卡片 ========== */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  cursor: grab;
  border-left: 4px solid var(--todo);
  transition: box-shadow .15s, transform .1s;
  user-select: none;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .45; }
.card.priority-high { border-left-color: var(--danger); }
.card.priority-medium { border-left-color: #f59e0b; }
.card.priority-low { border-left-color: #38bdf8; }
.card.overdue .card-due { color: var(--danger); font-weight: 700; }

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 4px;
  word-break: break-word;
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 10px;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
}

.tag {
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-priority-high { background: #fdecec; color: var(--danger); }
.tag-priority-medium { background: #fef3e2; color: #b45309; }
.tag-priority-low { background: #e5f5fe; color: #0369a1; }
.tag-project { background: #eef0f6; color: #4b5563; }
.tag-due { background: #fef3e2; color: #b45309; }
.tag-owner { background: #e9f8f1; color: #15803d; }

.card-done .card-title { text-decoration: line-through; color: var(--text-light); }

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 35, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--card-bg);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  padding: 24px 26px;
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease-out;
}

@keyframes pop {
  from { transform: scale(.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal h2 { font-size: 18px; margin-bottom: 18px; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-light); }
.required { color: var(--danger); }

.form-group input,
.form-group select,
.form-group textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fbfcfe;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); background: #fff; }

.form-row { display: flex; gap: 12px; }

.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.spacer { flex: 1; }

/* ========== 轻提示 ========== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2430;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: pop .2s ease-out;
}

/* ========== 到期提醒条 ========== */
.alert-banner {
  position: sticky;
  top: 65px;
  z-index: 9;
  max-width: 1344px;
  margin: 12px auto 0;
  padding: 10px 16px;
  background: #fff8e6;
  border: 1px solid #f5d78e;
  border-radius: 10px;
  color: #92400e;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.alert-banner:hover { background: #fff3d4; }
.alert-close {
  border: none;
  background: transparent;
  color: #92400e;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  flex-shrink: 0;
}
.alert-close:hover { background: rgba(146, 64, 14, .12); }

/* ========== AI 助理悬浮按钮与面板 ========== */
.assistant-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(79, 110, 247, .4);
  z-index: 90;
  transition: transform .15s;
}
.assistant-fab:hover { transform: scale(1.08); }
.assistant-fab:active { transform: scale(.95); }

.assistant-panel {
  position: fixed;
  right: 24px;
  bottom: 92px;
  width: 360px;
  max-width: calc(100vw - 40px);
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 95;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop .18s ease-out;
}

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--primary);
  color: #fff;
}
.assistant-title { font-weight: 700; font-size: 15px; }
.assistant-header-actions { display: flex; gap: 6px; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.assistant-header .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .4); }
.assistant-header .btn-ghost:hover { background: rgba(255, 255, 255, .15); }

.assistant-messages {
  height: 320px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f9fc;
}

.msg { max-width: 85%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg-user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.msg-bot { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 3px; box-shadow: var(--shadow); }

.assistant-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
  background: #f7f9fc;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  color: var(--text-light);
  cursor: pointer;
  transition: all .12s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }

.assistant-input {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  background: #f7f9fc;
  border-top: 1px solid var(--border);
}
.assistant-input input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
  outline: none;
}
.assistant-input input:focus { border-color: var(--primary); }

.voice-btn {
  background: #fff;
  border: 1px solid var(--border);
  font-size: 16px;
  padding: 8px 11px;
}
.voice-btn:hover { border-color: var(--primary); }
.voice-btn.listening {
  background: #fdecec;
  border-color: var(--danger);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ========== 日报弹窗 ========== */
.report-modal { max-width: 460px; }
.report-content {
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 4px;
}

/* ========== 项目管理弹窗 ========== */
.project-modal { max-width: 460px; }

.project-create { display: flex; gap: 8px; margin-bottom: 14px; }
.project-create input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  background: #fbfcfe;
}
.project-create input:focus { border-color: var(--primary); background: #fff; }

.project-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

.project-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}
.project-name { flex: 1; font-size: 14px; font-weight: 600; word-break: break-all; }
.project-tag {
  font-size: 11px;
  color: #92400e;
  background: #fef3e2;
  border-radius: 5px;
  padding: 2px 7px;
  flex-shrink: 0;
}
.project-row .btn { padding: 4px 9px; font-size: 12.5px; }
.proj-edit-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13.5px;
  outline: none;
}
.proj-edit-input:focus { border-color: var(--primary); }

/* ========== 手机端 H5 适配（置于末尾，确保覆盖基础样式） ========== */
@media (max-width: 768px) {
  /* iOS 防自动缩放：输入控件字号必须 ≥16px（<16px 聚焦时会放大页面） */
  .form-group input,
  .form-group textarea,
  .form-group select,
  .form-input,
  .project-create input,
  .proj-edit-input,
  .assistant-input input,
  .select-box,
  .voice-btn { font-size: 16px; }

  .topbar {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));  /* 添加到主屏幕全屏时避开刘海 */
    position: sticky;
    top: 0;
  }
  .logo { font-size: 17px; }
  .select-box { max-width: 132px; font-size: 13px; padding: 7px 10px; }
  .btn { padding: 8px 12px; font-size: 13px; }

  /* 统计条：横向滑动 */
  .stats {
    display: flex;
    gap: 10px;
    padding: 14px 16px 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .stats::-webkit-scrollbar { display: none; }
  .stat-card { min-width: 126px; padding: 10px 14px; flex-shrink: 0; }
  .stat-num { font-size: 18px; }

  /* 看板：横向滑动，每列接近屏幕宽 */
  .board {
    display: flex;
    gap: 12px;
    padding: 12px 16px 96px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .column {
    min-width: 76vw;
    max-height: calc(100dvh - 190px);  /* iOS 地址栏伸缩时更准确 */
    min-height: 300px;
    scroll-snap-align: start;
    flex-shrink: 0;
  }

  /* 弹窗：底部抽屉式 */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none;
    width: 100%;
    border-radius: 18px 18px 0 0;
    padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
    max-height: 90vh;
    overflow-y: auto;
  }
  .report-modal { max-width: none; }

  /* 助理面板：大屏半屏 */
  .assistant-fab { right: 16px; bottom: 16px; width: 52px; height: 52px; font-size: 24px; }
  .assistant-panel {
    right: 8px;
    bottom: 78px;
    left: 8px;
    width: auto;
    max-width: none;
    height: 68vh;
  }
  .assistant-messages { flex: 1; height: auto; }
  .assistant-input { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

  .alert-banner { margin: 10px 16px 0; }
  .card { padding: 11px 13px; }
}
