/* ============ 主容器与视野模式 ============ */
.app {
  max-width: 1520px;
  margin: 0 auto;
  padding: 14px 20px calc(70px + env(safe-area-inset-bottom, 0px));
  transition: max-width .28s ease;
}
.app[hidden] { display: none !important; }

html[data-view="medium"] .app { max-width: 820px; }
html[data-view="medium"] .card-grid { grid-template-columns: 1fr; }
html[data-view="medium"] .topbar { gap: 10px; }

/* ============ 顶栏 ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0 14px;
}
.brand { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.brand .logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 19px;
  box-shadow: var(--shadow);
}
.brand h1 { font-size: 18px; margin: 0; letter-spacing: 1px; font-weight: 800; line-height: 1.15; }
.brand p { margin: 1px 0 0; font-size: 10.5px; color: var(--text-3); letter-spacing: 1.8px; }

.search-wrap { flex: 1 1 160px; min-width: 130px; position: relative; }
.search-wrap input {
  width: 100%;
  height: 36px;
  padding: 0 30px 0 34px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
  appearance: none;
}
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.search-wrap::before {
  content: "🔍";
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12.5px;
  opacity: .55;
  pointer-events: none;
}
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-3);
  padding: 4px;
  line-height: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  max-width: 100%;
}
.top-actions .btn {
  height: 34px;
  padding: 0 11px;
  font-size: 12.5px;
  border-radius: 10px;
  gap: 5px;
}
.top-actions .btn.primary {
  padding: 0 13px;
}

.theme-switch, .view-switch {
  display: flex;
  align-items: center;
  height: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
  flex: 0 0 auto;
}
.theme-switch button, .view-switch button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  transition: .18s;
  opacity: .55;
  display: grid;
  place-items: center;
  line-height: 1;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.theme-switch button:hover, .view-switch button:hover { opacity: 1; background: var(--surface-2); }
.theme-switch button.active, .view-switch button.active {
  background: var(--accent);
  color: var(--accent-text);
  opacity: 1;
  box-shadow: var(--shadow);
}

/* 同步状态徽章 */
.sync-btn {
  color: var(--text-2);
}
.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--q2);
  display: inline-block;
  flex: 0 0 auto;
  transition: background .25s;
}
.sync-btn.syncing .sync-dot {
  background: var(--accent);
  animation: syncPulse 1s infinite ease-in-out;
}
.sync-btn.offline .sync-dot { background: var(--q3); }
.sync-btn.error .sync-dot { background: var(--q1); }
@keyframes syncPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: .5; }
}

/* 用户昵称防超宽截断 */
.user-name-label {
  display: inline-block;
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* 中等视野或中等屏幕下：折叠辅助按钮文字，保持顶栏紧凑单行不超宽 */
html[data-view="medium"] .top-actions .btn-label {
  display: none;
}
html[data-view="medium"] .top-actions .btn.icon-collapse {
  padding: 0 9px;
}
@media (max-width: 1100px) {
  .top-actions .btn-label {
    display: none;
  }
  .top-actions .btn.icon-collapse {
    padding: 0 9px;
  }
}

/* 管理员待审核角标 */
.badge-dot {
  background: var(--q1);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
  line-height: 1.25;
}

/* 咖啡休息按钮 */
.coffee-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  line-height: 1;
}
.coffee-btn .c-emoji { font-size: 15px; transition: transform .25s; }
.coffee-btn:hover .c-emoji { transform: rotate(-12deg) scale(1.12); }
.pomo-mini {
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 6px;
  padding: 2px 6px;
  letter-spacing: .3px;
}

/* ============ 时间轴 ============ */
.timeline {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 10px;
  margin-bottom: 12px;
}
.tl-nav {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: .18s;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.tl-nav:hover { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.tl-strip {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 8px, #000 calc(100% - 8px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 8px, #000 calc(100% - 8px), transparent);
}
.tl-strip::-webkit-scrollbar { display: none; }
.tl-day {
  flex: 0 0 auto;
  width: 56px;
  padding: 7px 0 6px;
  border-radius: 12px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: transform .16s, box-shadow .16s, background .16s, border-color .16s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.tl-day:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tl-w { font-size: 10px; color: var(--text-3); letter-spacing: .5px; }
.tl-d { font-size: 15px; font-weight: 700; line-height: 1.15; }
.tl-m { font-size: 9.5px; color: var(--text-3); }
.tl-day.sel { background: var(--accent); border-color: transparent; box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.tl-day.sel .tl-w, .tl-day.sel .tl-m { color: var(--accent-text); opacity: .85; }
.tl-day.sel .tl-d { color: var(--accent-text); }
.tl-day.is-today .tl-d::after {
  content: "";
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  margin: 2px auto 0;
}
.tl-day.sel.is-today .tl-d::after { background: var(--accent-text); }
.tl-dot {
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--q3);
  opacity: 0;
}
.tl-dot.on { opacity: 1; }
.tl-day.sel .tl-dot { opacity: 0; }

/* ============ 统计 & 工具栏 ============ */
.statsbar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-2);
  padding: 0 4px 12px;
}
.stat b { font-size: 14px; margin-right: 3px; color: var(--text); font-weight: 800; }
.stat.danger b { color: var(--q1); }
.stat.warn b { color: var(--q3); }
.stat.ok b { color: var(--q2); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 0 18px;
}
.filter-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  transition: .18s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.chip.active { background: var(--accent); color: var(--accent-text); border-color: transparent; box-shadow: var(--shadow); }

.sel {
  padding: 8px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  cursor: pointer;
  outline: none;
  color: var(--text);
  min-width: 0;
}
.sel:focus { border-color: var(--accent); }

/* ============ 看板 ============ */
.board { display: flex; flex-direction: column; gap: 34px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 14px; padding-left: 12px; position: relative; flex-wrap: wrap; }
.sec-head::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 4px;
  border-radius: 3px;
  background: var(--accent);
}
.sec-head h2 { font-size: 15px; font-weight: 800; margin: 0; letter-spacing: .6px; }
.sec-count {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 11.5px;
  color: var(--text-2);
  margin-left: 4px;
  font-weight: 700;
}
.sec-desc { font-size: 12px; color: var(--text-3); margin: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.empty {
  padding: 26px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ============ 卡片（去除重绘闪烁动画） ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 14px 16px 12px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--qc, var(--q4));
}
.card.q1 { --qc: var(--q1); }
.card.q2 { --qc: var(--q2); }
.card.q3 { --qc: var(--q3); }
.card.q4 { --qc: var(--q4); }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card.done { opacity: .68; }
.card.done .card-title { text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: var(--text-3); }

.card-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 10.5px;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .4px;
}
.badge.q1 { background: var(--q1-bg); color: var(--q1); }
.badge.q2 { background: var(--q2-bg); color: var(--q2); }
.badge.q3 { background: var(--q3-bg); color: var(--q3); }
.badge.q4 { background: var(--q4-bg); color: var(--q4); }
.badge.doing { background: var(--accent); color: var(--accent-text); }
.badge.done { background: var(--q2-bg); color: var(--q2); }

.card-title { font-size: 15.5px; font-weight: 750; margin: 0; line-height: 1.4; word-break: break-word; cursor: pointer; }
.card-sub { font-size: 12.5px; color: var(--text-2); margin: 0; line-height: 1.5; }
.card-text {
  font-size: 13px;
  color: var(--text-2);
  margin: 0;
  line-height: 1.62;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* 子任务清单（卡片内直接交互） */
.card-subtasks {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 10px;
}
.subtask-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 700;
}
.subtask-track {
  flex: 1;
  height: 5px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.subtask-fill {
  height: 100%;
  background: var(--q2);
  border-radius: 99px;
  transition: width .25s ease;
}
.subtask-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}
.subtask-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  margin: 0;
}
.subtask-item.st-done span {
  text-decoration: line-through;
  color: var(--text-3);
}

.card-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-3);
  padding-top: 2px;
}
.date-item {
  background: var(--surface-2);
  border-radius: 7px;
  padding: 3px 8px;
  display: inline-flex;
  gap: 5px;
  align-items: center;
}
.date-item i { font-style: normal; opacity: .65; font-size: 10.5px; }
.rem { padding: 3px 9px; border-radius: 7px; font-weight: 700; font-size: 11.5px; }
.rem.danger { background: var(--q1-bg); color: var(--q1); }
.rem.warn { background: var(--q3-bg); color: var(--q3); }
.rem.ok { background: var(--q4-bg); color: var(--text-2); }
.rem.neutral { background: var(--q2-bg); color: var(--q2); }

.card-prog {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 11px;
  border-left: 3px solid var(--accent);
}
.prog-head { font-size: 10.5px; color: var(--text-3); font-weight: 700; letter-spacing: .4px; margin-bottom: 3px; }
.prog-text {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-note {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
  background: var(--q2-bg);
  border-radius: 10px;
  padding: 8px 11px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 9px;
  margin-top: auto;
  border-top: 1px dashed var(--line);
}
.act {
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  padding: 5px 11px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  transition: .16s;
  color: var(--text-2);
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.act:hover { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.act.ok:hover { background: var(--q2); color: #fff; border-color: transparent; }
.act.warn:hover { background: var(--q3); color: #fff; border-color: transparent; }
.act.focus { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.act.focus:hover { background: var(--accent); color: var(--accent-text); border-color: transparent; }

/* 移动端悬浮新建按钮（桌面端默认隐藏） */
.mobile-fab {
  display: none;
}

