/* ===== 基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5; color: #1d1d1f; overflow: hidden;
  height: 100vh; width: 100vw;
}

/* ===== 图谱容器 ===== */
#graph-container {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: #f8f9fa;
}
#graph-container canvas { display: block; }

/* ===== 顶部栏 ===== */
#toolbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 16px;
  display: flex; align-items: center;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
#app-title { font-size: 17px; font-weight: 700; color: #1d1d1f; }
#app-subtitle { font-size: 13px; color: #86868b; margin-left: 8px; flex: 1; }
#toolbar-actions { margin-left: auto; }
.tool-btn {
  background: none; border: 1.5px solid #ddd; border-radius: 8px;
  padding: 6px 10px; font-size: 18px; cursor: pointer;
  transition: all 0.2s; line-height: 1;
}
.tool-btn:hover { border-color: #667eea; background: #f0f2ff; }
.tool-btn.active { border-color: #667eea; background: #667eea; color: #fff; }

#connect-hint {
  position: fixed; top: 52px; left: 0; right: 0; z-index: 150;
  background: #667eea; color: #fff; text-align: center;
  padding: 8px; font-size: 14px; font-weight: 500;
  transition: all 0.3s;
}
#connect-hint.hidden { transform: translateY(-100%); }

/* ===== 浮动按钮 ===== */
#fab-menu {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.fab {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff; border: none; font-size: 28px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(102,126,234,0.4);
  transition: all 0.2s; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.fab:active { transform: scale(0.92); }
.fab-sm { width: 44px; height: 44px; font-size: 20px; background: linear-gradient(135deg, #4ecdc4, #44bd9e); }

/* ===== 弹窗 ===== */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 500; }
.modal.hidden { display: none; }
.modal-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
}
.modal-content {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 16px 16px 0 0;
  max-height: 85vh; overflow-y: auto;
  padding: 0; animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid #eee;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 24px; color: #999;
  cursor: pointer; padding: 4px 8px; line-height: 1;
}

/* ===== 表单 ===== */
form { padding: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 14px; font-weight: 500;
  color: #555; margin-bottom: 6px;
}
.form-row { display: flex; gap: 12px; }
.form-group.half { flex: 1; }
input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid #e0e0e0;
  border-radius: 10px; font-size: 15px; background: #fafafa;
  transition: border-color 0.2s; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: #667eea; background: #fff;
}
textarea { resize: vertical; }

/* 头像上传 */
.photo-upload {
  position: relative; width: 100%; height: 160px;
  border: 2px dashed #ddd; border-radius: 12px;
  overflow: hidden; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: #fafafa;
}
.photo-upload:active { background: #f0f0f0; }
.photo-upload input[type="file"] {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.photo-placeholder {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; color: #999;
}
.photo-placeholder span:first-child { font-size: 40px; }
.photo-placeholder span:last-child { font-size: 13px; }
#photo-preview {
  width: 100%; height: 100%; object-fit: cover; position: absolute;
  top: 0; left: 0;
}

/* 按钮 */
.form-actions {
  display: flex; gap: 12px; margin-top: 20px;
  padding-top: 16px; border-top: 1px solid #eee;
}
.btn {
  flex: 1; padding: 12px; border: none; border-radius: 12px;
  font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #667eea; color: #fff; }
.btn-cancel { background: #f0f0f0; color: #555; }

/* ===== 详情侧栏 ===== */
#detail-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 300;
  background: #fff; border-radius: 16px 16px 0 0;
  max-height: 50vh; overflow-y: auto;
  transition: transform 0.3s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}
#detail-panel.hidden { transform: translateY(100%); }
#detail-content { padding: 20px; }
#detail-content .person-card {
  display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
}
#detail-content .person-card img {
  width: 60px; height: 60px; border-radius: 50%; object-fit: cover;
  border: 3px solid #f0f0f0;
}
#detail-content .person-card .no-photo {
  width: 60px; height: 60px; border-radius: 50%; background: #f0f0f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #ccc; border: 3px solid #f0f0f0;
}
#detail-content .person-info h3 { font-size: 18px; margin-bottom: 4px; }
#detail-content .person-info p { font-size: 13px; color: #888; }

#detail-content .section-title {
  font-size: 14px; font-weight: 600; color: #555; margin: 12px 0 8px;
  padding-top: 12px; border-top: 1px solid #eee;
}
#detail-content .rel-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
}
#detail-content .rel-item .rel-click {
  display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer;
}
#detail-content .rel-item .rel-click:active { opacity: 0.6; }
#detail-content .rel-item img {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
}
.rel-edit-btn {
  background: none; border: none; font-size: 14px; padding: 4px 6px;
  cursor: pointer; opacity: 0.4; transition: opacity 0.2s; border-radius: 6px;
}
.rel-edit-btn:active { background: #f0f0f0; opacity: 1; }
#detail-content .rel-item .no-photo-sm {
  width: 36px; height: 36px; border-radius: 50%; background: #f0f0f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #ccc;
}
#detail-content .rel-item .rel-info { flex: 1; }
#detail-content .rel-item .rel-info .rel-name { font-size: 14px; font-weight: 500; }
#detail-content .rel-item .rel-info .rel-label { font-size: 12px; color: #888; }

.detail-actions {
  display: flex; gap: 10px; margin-top: 16px;
}
.detail-actions .btn { flex: 1; }
.btn-danger { background: #ff4757; color: #fff; }
.btn-secondary { background: #f0f0f0; color: #555; }

/* ===== 空状态 ===== */
#empty-state {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; color: #999; z-index: 10;
}
#empty-state span { font-size: 48px; display: block; margin-bottom: 12px; }
#empty-state p { font-size: 15px; }

/* ===== 提示 Toast ===== */
.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: #fff; padding: 10px 20px;
  border-radius: 8px; font-size: 14px; z-index: 999;
  animation: toastIn 0.3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
