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

body {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: #faf8f5;
  color: #3d3d3d;
  min-height: 100vh;
  padding-bottom: 100px;
}

/* ===== 头部 ===== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,248,245,0.92);
  backdrop-filter: blur(12px);
  padding: 20px 20px 12px;
  text-align: center;
  border-bottom: 1px solid #eee8dd;
}
header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 4px;
  color: #5a5a5a;
  margin-bottom: 12px;
}
nav { display: flex; justify-content: center; gap: 8px; }
.nav-btn {
  padding: 6px 18px;
  border: 1px solid #e0dcd5;
  border-radius: 20px;
  background: #fffdf9;
  color: #8a8a8a;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.nav-btn:hover { border-color: #c5bfb0; color: #5a5a5a; }
.nav-btn.active { background: #5a5a5a; color: #fff; border-color: #5a5a5a; }

/* ===== 视图切换 ===== */
.view { display: none; }
.view.active { display: block; }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 80px 20px; color: #b0a99c; font-size: 15px; }
.empty-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.5; }

/* ===== 浮动上传按钮 ===== */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #5a5a5a;
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 90;
  transition: transform 0.2s, box-shadow 0.2s;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,0.2); }

/* ===== 时间线 ===== */
.timeline {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 20px 40px 48px;
  position: relative;
}
/* 时间线竖轴 */
.timeline::before {
  content: '';
  position: absolute;
  left: 28px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e0dcd5;
}
.date-group {
  position: relative;
  margin-bottom: 36px;
}
.date-label {
  position: relative;
  left: -20px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #b0a99c;
  font-weight: 500;
}
.date-label::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c5bfb0;
}
.date-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.photo-card {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: #e8e5df;
  aspect-ratio: 1;
  transition: transform 0.2s;
}
.photo-card:hover { transform: scale(1.03); }
.photo-card img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 人物标签 */
.people-tags {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 3px;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.45));
}
.people-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.photo-desc {
  position: absolute;
  bottom: 20px;
  left: 6px;
  right: 6px;
  font-size: 11px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== 关系图 ===== */
.graph-area {
  position: relative;
  max-width: 500px;
  margin: 32px auto 0;
  height: 200px;
}
.graph-nodes {
  display: flex;
  justify-content: center;
  gap: 48px;
  padding-top: 40px;
}
.graph-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: grab;
  user-select: none;
  transition: transform 0.2s;
}
.graph-node:active { cursor: grabbing; }
.graph-node.dragging { transform: scale(1.12); }
.graph-node.selected .node-avatar { box-shadow: 0 0 0 3px #5a5a5a; }
.node-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  transition: box-shadow 0.2s;
}
.node-name { font-size: 13px; color: #8a8a8a; }

#graphSvg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}
#graphSvg line {
  stroke: #c5bfb0;
  stroke-width: 2;
  stroke-dasharray: 6 3;
}

.graph-hint {
  text-align: center;
  font-size: 13px;
  color: #c5bfb0;
  margin: 8px 0 24px;
}

.graph-gallery {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 40px;
  columns: 3;
  column-gap: 10px;
}
.graph-gallery .photo-card {
  break-inside: avoid;
  margin-bottom: 10px;
  aspect-ratio: auto;
}

/* ===== 弹窗 ===== */
.modal { display: none; }
.modal.show { display: block; }
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
}
.modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fffdf9;
  border-radius: 14px;
  padding: 28px;
  z-index: 201;
  width: 90%;
  max-width: 440px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal-content h2 {
  font-size: 18px;
  margin-bottom: 20px;
  text-align: center;
}

/* 设置页 */
.rm-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.rm-color {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
}
.rm-name {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e0dcd5;
  border-radius: 6px;
  font-size: 14px;
  background: #fffefc;
  outline: none;
}
.rm-name:focus { border-color: #b8a88a; }

/* 上传弹窗 */
.upload-modal { max-width: 600px; }
.upload-dropzone {
  border: 2px dashed #e0dcd5;
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  color: #b0a99c;
  margin-bottom: 16px;
  transition: all 0.2s;
}
.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: #b8a88a;
  background: #fdfaf3;
}
#batchTags {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #f8f5ef;
  border-radius: 8px;
}
#batchTags.show { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.batch-label { font-size: 13px; color: #8a8a8a; }
.batch-checkboxes { display: flex; gap: 8px; }
.batch-checkboxes label {
  display: flex; align-items: center; gap: 3px;
  font-size: 13px; cursor: pointer;
}
.batch-date {
  padding: 6px 10px; border: 1px solid #e0dcd5;
  border-radius: 6px; font-size: 13px;
  background: #fffefc; outline: none;
  color: #5a5a5a;
}
.batch-desc {
  flex: 1; min-width: 160px;
  padding: 6px 10px; border: 1px solid #e0dcd5;
  border-radius: 6px; font-size: 13px;
  background: #fffefc; outline: none;
}

.preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.preview-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #e8e5df;
}
.preview-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.preview-item .item-overlay {
  padding: 6px 8px;
  background: #fffefc;
  border-top: 1px solid #f0ede5;
}
.item-checkboxes {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.item-checkboxes label {
  display: flex; align-items: center; gap: 1px;
  font-size: 11px; cursor: pointer;
}
.item-desc {
  width: 100%;
  margin-top: 4px;
  padding: 3px 6px;
  border: 1px solid #e0dcd5;
  border-radius: 4px;
  font-size: 11px;
  outline: none;
}

.upload-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
.upload-info { font-size: 13px; color: #8a8a8a; margin-right: auto; }

.btn {
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.btn-primary { background: #5a5a5a; color: #fff; }
.btn-primary:hover { background: #4a4a4a; }
.btn-ghost { background: transparent; color: #8a8a8a; border: 1px solid #e0dcd5; }
.btn-ghost:hover { border-color: #b0a99c; color: #5a5a5a; }

.upload-status { text-align: center; font-size: 13px; color: #8a8a8a; margin-top: 8px; min-height: 20px; }

.progress-bar {
  margin-top: 8px;
  height: 3px;
  background: #eee;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.3s;
}
.progress-bar.active { opacity: 1; }
.progress-fill {
  height: 100%;
  background: #b8a88a;
  border-radius: 2px;
  width: 0%;
  transition: width 0.4s;
}

/* ===== 灯箱 ===== */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 24px;
  font-size: 34px; color: #fff;
  background: none; border: none;
  cursor: pointer; opacity: 0.7; z-index: 301;
}
.lightbox-close:hover { opacity: 1; }
.lightbox-prev, .lightbox-next {
  position: absolute; top: 50%;
  transform: translateY(-50%);
  font-size: 44px; color: #fff;
  background: none; border: none;
  cursor: pointer; opacity: 0.5;
  padding: 16px; transition: opacity 0.2s;
}
.lightbox-prev:hover, .lightbox-next:hover { opacity: 1; }
.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }
.lightbox-info {
  position: absolute;
  bottom: 76px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  color: #fff; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  background: rgba(0,0,0,0.5);
  padding: 6px 16px;
  border-radius: 16px;
}
.lightbox-info .people-dot { width: 10px; height: 10px; }
.lightbox-desc-text { margin-left: 8px; opacity: 0.8; }

/* 灯箱底部操作栏 */
.lightbox-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 20px 20px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  z-index: 301;
}
.lightbox-bar-btn {
  padding: 10px 22px;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s;
}
.lightbox-bar-btn:hover { background: rgba(255,255,255,0.25); }
.lightbox-bar-btn.danger:hover { background: rgba(220,60,60,0.6); border-color: rgba(220,60,60,0.7); }

.lightbox-edit-panel {
  position: absolute;
  bottom: 80px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 302;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 16px 20px;
  border: 1px solid rgba(255,255,255,0.15);
}
.edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}
.edit-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.edit-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: #b8a88a;
}
.lightbox-edit-panel input[type="text"] {
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 15px;
  outline: none;
  width: 240px;
}
.lightbox-edit-panel input[type="text"]::placeholder { color: rgba(255,255,255,0.4); }
.lightbox-edit-panel .btn {
  border-radius: 20px;
  white-space: nowrap;
}
.edit-actions { justify-content: center; gap: 12px; }

/* ===== 响应式 ===== */
@media (max-width: 600px) {
  .timeline { padding-left: 36px; }
  .timeline::before { left: 18px; }
  .date-label::before { left: -12px; width: 6px; height: 6px; }
  .date-photos { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .graph-nodes { gap: 20px; }
  .node-avatar { width: 42px; height: 42px; font-size: 15px; }
  .graph-gallery { columns: 2; }
  .fab { bottom: 20px; right: 20px; width: 46px; height: 46px; font-size: 24px; }
  .preview-list { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}
