/* onelife - 人生管理系统 前端样式 */
:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --primary: #4f6ef7;
  --primary-dark: #3a55d9;
  --text: #1f2330;
  --text-2: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #10b981;
  --warn: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- 登录页 ---------- */
#login-view {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
#login-view.active { display: flex; }
.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card .logo { font-size: 44px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card p { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
}
.login-card input:focus { border-color: var(--primary); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  background: var(--primary);
  color: #fff;
  width: 100%;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn.secondary { background: #eef0f6; color: var(--text); }
.btn.danger { background: #fee2e2; color: var(--danger); }
.btn.small { padding: 6px 12px; width: auto; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; color: var(--primary); box-shadow: none; width: auto; padding: 6px 10px; }

/* ---------- 主界面 ---------- */
#app-view { display: none; }
#app-view.active { display: block; }
header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.header-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-inner .logo { font-size: 24px; }
.header-inner h1 { font-size: 18px; flex: 1; white-space: nowrap; }
.header-inner .btn.small { width: auto; }

main { max-width: 800px; margin: 0 auto; padding: 16px; }

/* 生日横幅 */
#birthday-bar {
  display: none;
  background: linear-gradient(135deg, #fff7e6, #fff3d6);
  border: 1px solid #fde8b8;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #92610a;
}
#birthday-bar.active { display: block; }
#birthday-bar strong { margin-right: 8px; }
.bday-item { display: inline-block; margin: 2px 10px 2px 0; }
.bday-item .badge {
  display: inline-block;
  background: var(--warn);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 8px;
  margin-left: 4px;
}

/* 工具栏 */
.toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type="search"] {
  flex: 1;
  min-width: 160px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
.toolbar input:focus { border-color: var(--primary); }
.tag-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tag-chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-2);
}
.tag-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 朋友卡片网格 */
.friend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.friend-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  border: 1px solid transparent;
}
.friend-card:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); }
.friend-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.friend-name { font-size: 16px; font-weight: 700; }
.friend-nick { color: var(--text-2); font-size: 13px; margin-top: 1px; }
.friend-meta { color: var(--text-2); font-size: 13px; line-height: 1.6; }
.friend-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.mini-tag {
  font-size: 11px;
  background: #eef2ff;
  color: var(--primary-dark);
  border-radius: 6px;
  padding: 2px 8px;
}
.stars { color: var(--warn); font-size: 12px; letter-spacing: 1px; }
.score-badge {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  margin-left: 4px;
}
.friend-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-2);
}

/* 空状态 */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
}
.empty .big { font-size: 48px; margin-bottom: 12px; }

/* ---------- 详情视图 ---------- */
#detail-view { display: none; }
#detail-view.active { display: block; }
#settings-view { display: none; }
#settings-view.active { display: block; }
.detail-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.detail-head .avatar { width: 56px; height: 56px; font-size: 24px; }
.detail-head h2 { font-size: 20px; }
.detail-head .sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.detail-actions { margin-left: auto; display: flex; gap: 6px; }
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 16px;
  font-size: 14px;
}
.info-item .k { color: var(--text-2); font-size: 12px; margin-bottom: 2px; }
.info-item .v { font-weight: 500; word-break: break-all; }
.notes-box {
  margin-top: 14px;
  background: #fafbfc;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* 互动时间线 */
.section-title { font-size: 16px; font-weight: 700; margin: 20px 0 12px; display: flex; align-items: center; gap: 8px; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}
.tl-item { position: relative; margin-bottom: 14px; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}
.tl-item.help::before { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.tl-item.gift::before { background: var(--warn); box-shadow: 0 0 0 2px var(--warn); }
.tl-item.meeting::before { background: #8b5cf6; box-shadow: 0 0 0 2px #8b5cf6; }
.tl-card {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.6;
}
.tl-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.tl-type {
  font-size: 11px;
  background: #eef2ff;
  color: var(--primary-dark);
  border-radius: 6px;
  padding: 1px 8px;
}
.tl-date { color: var(--text-2); font-size: 12px; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-item label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.form-item input, .form-item select, .form-item textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  outline: none;
  background: #fff;
  font-family: inherit;
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); }
.form-item textarea { min-height: 70px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.form-actions .btn { flex: 1; }

/* 弹窗 */
.modal-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}
.modal-mask.active { display: flex; }
.modal {
  background: #fff;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 28px;
}
.modal h3 { font-size: 17px; margin-bottom: 16px; }
.modal-close { float: right; cursor: pointer; color: var(--text-2); font-size: 20px; }

/* toast */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1f2330;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  transition: transform 0.25s;
  pointer-events: none;
  opacity: 0;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* 板块导航 */
.section-nav {
  display: flex;
  gap: 2px;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-tab {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-tab.active {
  background: #eef2ff;
  color: var(--primary-dark);
}
.nav-tab:hover { background: #f4f5f7; }

/* 目标板块 */
.goal-toolbar { margin-bottom: 12px; }
.goal-status-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.goal-progress-block { margin-top: 10px; }
.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 4px;
}
.progress-pct { font-weight: 700; color: var(--primary-dark); }
.progress-bar {
  height: 8px;
  background: #eef0f6;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8b5cf6);
  border-radius: 999px;
  transition: width 0.4s;
}

/* KR 卡片 */
.kr-list { display: flex; flex-direction: column; gap: 10px; }
.kr-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.kr-card.kr-done { border-left-color: var(--success); opacity: 0.75; }
.kr-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.kr-title { font-size: 14px; font-weight: 600; word-break: break-all; }
.kr-actions { display: flex; gap: 4px; flex-shrink: 0; }
.kr-number-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.kr-current-input {
  width: 80px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.kr-current-input:focus { border-color: var(--primary); }
.kr-slash, .kr-target { font-size: 14px; }
.kr-target { color: var(--text-2); }
.kr-pct { font-weight: 700; color: var(--primary-dark); font-size: 14px; }

/* 响应式 */
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .header-inner h1 { font-size: 16px; }
  .friend-grid { grid-template-columns: 1fr; }
}
