:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #1a1a1a;
  --text-2: #666;
  --text-3: #999;
  --border: #e5e6ea;
  --primary: #4f6ef7;
  --primary-2: #3d5af1;
  --danger: #e5484d;
  --success: #2e9e5b;
  --warning: #d98b00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.5;
}
.hidden { display: none !important; }

/* 登录 */
.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 40px 36px; text-align: center; width: 340px; }
.logo { font-size: 48px; }
.login-card h1 { font-size: 20px; font-weight: 600; margin-top: 10px; }
.subtitle { color: var(--text-2); margin: 6px 0 22px; font-size: 13px; }

/* 按钮 */
.btn-primary { background: var(--primary); color: #fff; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; }
.btn-primary:hover { background: var(--primary-2); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: #fdeceb; color: var(--danger); border: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.btn-danger:hover { background: #fadbd9; }
.error-text { color: var(--danger); margin-top: 10px; font-size: 12px; min-height: 18px; }

/* 布局 */
.app-view { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 64px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 14px 0; flex-shrink: 0; }
.sidebar-logo { font-size: 22px; margin-bottom: 16px; }
.nav { flex: 1; display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 0 8px; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; padding: 8px 0; border-radius: 8px; cursor: pointer; color: var(--text-2); width: 100%; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: #eef1ff; color: var(--primary); }
.nav-icon { font-size: 18px; }
.nav-text { font-size: 10px; }
.sidebar-footer { display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 0 8px; align-items: center; }
.user-name { font-size: 10px; color: var(--text-3); max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 20px; }
.view { max-width: 1400px; margin: 0 auto; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.view-title { font-size: 16px; font-weight: 600; }
.view-toggle { display: flex; background: var(--surface-2); border-radius: 6px; padding: 2px; }
.toggle-btn { border: none; background: none; padding: 3px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; color: var(--text-2); }
.toggle-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* ===== 按日分列时间轴 ===== */
.timeline-axis-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.timeline-axis-head .axis-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  position: relative;
}
.timeline-axis-head .axis-line::after {
  content: '→';
  position: absolute;
  right: -2px;
  top: -10px;
  font-size: 14px;
  color: var(--text-3);
}
.timeline-day-group {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 4px 12px;
  align-items: flex-start;
}
.timeline-day {
  flex: 0 0 auto;
  width: 170px;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.timeline-day-header {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  text-align: center; padding: 2px 0;
}
.timeline-day-header.today { color: var(--primary); }
.timeline-day-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tblock {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.tblock:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.tblock .tb-date {
  font-size: 11px; color: var(--primary); font-weight: 600; margin-bottom: 4px;
  display: flex; justify-content: space-between; align-items: center;
}
.tblock.type-event .tb-date { color: var(--success); }
.tblock.done .tb-date { color: var(--text-3); }
.tblock .tb-title { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tblock.done .tb-title { color: var(--text-3); text-decoration: line-through; }
.tblock .tb-meta { font-size: 10px; color: var(--text-3); margin-top: 4px; }
.tb-type-tag { font-size: 10px; color: var(--primary); background: #eef1ff; padding: 0 6px; border-radius: 6px; }

/* 未设时间（可排序） */
.untimed-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 20px 0 8px; }
.untimed-list { display: flex; flex-wrap: wrap; gap: 8px; min-height: 40px; }
.untimed-card {
  background: var(--surface); border: 1px dashed var(--border); border-radius: 8px;
  padding: 8px 12px; display: flex; align-items: center; gap: 8px; cursor: grab;
}
.untimed-card.dragging { opacity: 0.5; }
.untimed-card .t-title { font-size: 12px; font-weight: 500; }
.untimed-card .t-type { font-size: 10px; color: var(--text-3); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.untimed-card .drag-handle { cursor: grab; color: var(--text-3); font-size: 14px; }

/* ===== 空间列表 ===== */
.space-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.space-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; cursor: pointer; transition: box-shadow .15s; }
.space-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.space-card .s-icon { font-size: 24px; }
.space-card .s-name { font-size: 14px; font-weight: 600; margin-top: 8px; }
.space-card .s-meta { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.space-card .s-kind { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 6px; margin-top: 6px; }
.kind-timeline { background: #eef1ff; color: var(--primary); }
.kind-collection { background: #e8f5ee; color: var(--success); }

.space-detail-head { display: flex; align-items: center; gap: 10px; }

/* 学业区课程 tab */
.course-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.ctab {
  border: none;
  background: none;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.ctab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* 分数组成表格 */
.score-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.score-table th, .score-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.score-table th { background: var(--surface-2); color: var(--text-2); font-weight: 500; }
.score-table tr:last-child td { border-bottom: none; }
.score-table .score-total-row td { background: #eef1ff; font-weight: 600; color: var(--primary); border-top: 2px solid var(--primary); }

/* ===== 看板 ===== */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.board { background: var(--surface-2); border-radius: var(--radius); padding: 10px; }
.board-header { display: flex; justify-content: space-between; align-items: center; padding: 0 2px 6px; }
.board-title { font-size: 13px; font-weight: 600; }
.board-progress { font-size: 11px; color: var(--text-2); background: var(--surface); padding: 1px 7px; border-radius: 8px; }
.board-columns { display: flex; gap: 6px; }
.board-col { background: var(--surface); border-radius: 8px; flex: 1; min-width: 90px; display: flex; flex-direction: column; max-height: 320px; }
.board-col-header { padding: 6px 8px; font-size: 11px; font-weight: 600; color: var(--text-2); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.col-count { font-weight: 400; color: var(--text-3); font-size: 10px; }
.board-col-body { padding: 6px; flex: 1; overflow-y: auto; min-height: 50px; display: flex; flex-direction: column; gap: 5px; }
.board-col-body.drag-over { background: #eef1ff; outline: 2px dashed var(--primary); outline-offset: -2px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; cursor: grab; box-shadow: 0 1px 1px rgba(0,0,0,0.03); }
.kcard:hover { box-shadow: 0 1px 6px rgba(0,0,0,0.1); }
.kcard.dragging { opacity: 0.5; }
.kcard-title { font-size: 12px; font-weight: 500; }
.kcard-meta { font-size: 10px; color: var(--text-3); margin-top: 2px; }
.col-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot-todo { background: var(--primary); }
.dot-doing { background: var(--warning); }
.dot-done { background: var(--success); }

.badge { display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 10px; font-weight: 500; }
.badge-priority-high { background: #fdeceb; color: var(--danger); }
.badge-priority-medium { background: #fff3dd; color: var(--warning); }
.badge-priority-low { background: #e8f5ee; color: var(--success); }

/* ===== 滑块（属性切换） ===== */
.switch-field { display: flex; align-items: center; gap: 10px; }
.switch {
  position: relative; width: 44px; height: 24px; background: #c5c7cc;
  border-radius: 12px; cursor: pointer; transition: background .2s; flex-shrink: 0;
}
.switch.on { background: var(--primary); }
.switch.collection { background: var(--success); }
.switch .knob {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; transition: left .2s;
}
.switch.on .knob, .switch.collection .knob { left: 22px; }
.switch-label { font-size: 13px; color: var(--text-2); }

/* 三态属性分段选择 */
.kind-segment {
  display: flex;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}
.kseg {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.kseg.active { background: var(--primary); color: #fff; font-weight: 500; }

/* 图标库选择器 */
.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.icon-opt {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.icon-opt:hover { background: var(--surface-2); }
.icon-opt.active { background: #eef1ff; border-color: var(--primary); }

/* ===== 弹窗 ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: 0 8px 32px rgba(0,0,0,0.2); padding: 22px; width: 520px; max-width: 92vw; max-height: 86vh; overflow-y: auto; }
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: inherit; outline: none;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 60px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 7px 14px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.btn-secondary:hover { background: var(--border); }
.field-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.field-row input, .field-row select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; flex: 1; }
.field-row input:nth-child(1) { flex: 1.4; }

/* 附件 */
.attach-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photo-actions { display: flex; flex-direction: column; gap: 6px; }

/* 日期选择按钮（大而醒目） */
.time-picker-btn {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  border: 1px dashed var(--primary);
  border-radius: 8px;
  background: #f5f7ff;
  color: var(--primary);
  cursor: pointer;
  text-align: center;
  transition: background .15s;
}
.time-picker-btn:hover { background: #eef1ff; }
.time-picker-btn.has-value { border-style: solid; color: var(--text); background: var(--surface); }
.attach-item { position: relative; }
.attach-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.attach-item .attach-name { font-size: 10px; color: var(--text-2); max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-remove { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; background: var(--danger); color: #fff; border: none; cursor: pointer; font-size: 10px; line-height: 18px; text-align: center; }

/* 进度条/评分 预览 */
.range-field { display: flex; align-items: center; gap: 8px; }
.range-field input[type=range] { flex: 1; }
.range-val { font-size: 12px; color: var(--text-2); min-width: 30px; text-align: center; }

/* Toast */
.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 13px; z-index: 200; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
.empty { color: var(--text-3); text-align: center; padding: 24px 0; font-size: 12px; }

/* 手机 tab */
.mobile-tab { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 60; }
.mtab-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; padding: 7px 0; cursor: pointer; color: var(--text-2); font-size: 10px; }
.mtab-item.active { color: var(--primary); }
.mtab-item span { font-size: 10px; }

/* 响应式 */
@media (max-width: 640px) {
  .app-view { height: auto; min-height: 100vh; }
  .sidebar { display: none; }
  .main { padding: 12px 12px 72px; }
  .mobile-tab { display: flex; }
  .view-title { font-size: 15px; }
  .space-list { grid-template-columns: repeat(2, 1fr); }
  .board-grid { grid-template-columns: 1fr; }
  .board-columns { overflow-x: auto; }
  .board-col { min-width: 130px; }
  .modal { padding: 18px; }
  .tblock { width: 130px; }
}
@media (min-width: 641px) {
  .mobile-tab { display: none; }
}
