/* ------------------ 基础重置与全局样式 - 优化版 ------------------ */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans SC', sans-serif;
  background: linear-gradient(180deg, #f8f9fb 0%, #f2f3f7 100%);
  color: #1d1d1f;
  line-height: 1.6;
  padding-bottom: 40px;
  min-height: 100vh;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ------------------ 选项卡 - 增强视觉与动效 ------------------ */
.tab-nav {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 8px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(8px);
}

.tab-item {
  flex: 1;
  padding: 12px 10px;
  text-align: center;
  border-radius: 14px;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: #6e6e73;
  position: relative;
  overflow: hidden;
}

.tab-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.6s ease;
}

.tab-item:hover::before {
  left: 100%;
}

.tab-item.active {
  background: linear-gradient(135deg, #5273f7 0%, #4361ee 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(82, 115, 247, 0.3);
}

.tab-item:hover:not(.active) {
  background: #f5f6f8;
  color: #4361ee;
  transform: translateY(-1px);
}

/* ------------------ 页面切换 ------------------ */
.page {
  display: none;
  animation: fadeOut 0.3s ease;
}

.page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ------------------ 页面头部 ------------------ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #1d1d1f;
  position: relative;
  padding-bottom: 8px;
}

.page-header h2::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 40px;
  height: 3px;
  background: linear-gradient(90deg, #5273f7, #7b93f9);
  border-radius: 3px;
}

/* ------------------ 按钮 - 渐变+微动效优化 ------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #5273f7 0%, #4361ee 100%);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 10px 18px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(82, 115, 247, 0.25);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.btn:hover::before {
  transform: translateX(100%);
}

.btn-secondary {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  color: #1d1d1f;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 12px;
}

.btn-danger {
  background: linear-gradient(135deg, #ff3b30 0%, #ff2d20 100%);
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.25);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(82, 115, 247, 0.3);
}

.btn-secondary:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.btn:active {
  transform: translateY(0) scale(0.97);
}

/* ------------------ 卡片列表 - 瀑布流+自适应图片版 ------------------ */
.card-grid {
  column-count: 3; /* 桌面端3列 */
  column-gap: 20px;
}

.card {
  background: linear-gradient(180deg, #ffffff 0%, #fefefe 100%);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  border: 1px solid rgba(255,255,255,0.8);
  /* 瀑布流关键：防止卡片被切断 */
  break-inside: avoid;
  margin-bottom: 20px;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.card-img {
  width: 100%;
  height: auto; /* 完全自适应高度 */
  display: block; /* 消除图片下方默认间隙 */
  transition: transform 0.5s ease;
}

.card:hover .card-img {
  transform: scale(1.03);
}

.card-img-empty {
  width: 100%;
  min-height: 50px; /* 空状态最小高度 */
  background: linear-gradient(135deg, #f5f6f8 0%, #e9ecef 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 48px;
}

.card-body {
  padding: 20px 16px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1d1d1f;
}

.card-sub {
  font-size: 14px;
  color: #6e6e73;
  margin-bottom: 6px;
}

.card-info {
  font-size: 13px;
  color: #8e8e93;
  line-height: 1.5;
}

/* 卡片操作按钮 - 优化动效 */
.card-graph {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 2;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

.card-graph:hover {
  background: linear-gradient(135deg, #5273f7 0%, #4361ee 100%);
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 6px 12px rgba(82, 115, 247, 0.3);
}

.card-delete {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  z-index: 2;
  transition: all 0.3s ease;
  color: #ff3b30;
  opacity: 0;
  backdrop-filter: blur(4px);
}

.card:hover .card-delete {
  opacity: 1;
  transform: translateY(0);
}

.card-delete:hover {
  background: linear-gradient(135deg, #ff3b30 0%, #ff2d20 100%);
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 6px 12px rgba(255, 59, 48, 0.3);
}

/* ------------------ 生日卡片 ------------------ */
.birthday-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #f0f5ff 0%, #e6f0ff 100%);
  border-radius: 20px;
  border: 1px solid #e0e7ff;
}

.birthday-day {
  font-size: 32px;
  font-weight: 700;
  color: #5273f7;
  background: rgba(255,255,255,0.8);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(82, 115, 247, 0.2);
}

.birthday-info {
  flex: 1;
  margin-left: 16px;
}

/* ------------------ 弹窗 - 增强层次感与动效 ------------------ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(4px);
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: linear-gradient(180deg, #ffffff 0%, #fefefe 100%);
  border-radius: 24px;
  width: 90%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  transform: translateY(20px) scale(0.98);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255,255,255,0.9);
}

.modal.show .modal-box {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #f5f6f8;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
  color: #1d1d1f;
}

.modal-close {
  background: #f5f6f8;
  border: none;
  font-size: 24px;
  color: #6e6e73;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #e9ecef;
  color: #ff3b30;
  transform: rotate(90deg);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #f5f6f8;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ------------------ 表单样式 - 优化视觉层次 ------------------ */
.form-section {
  background: linear-gradient(135deg, #f9fafb 0%, #f5f6f8 100%);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid rgba(255,255,255,0.7);
}

.form-section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1d1d1f;
  padding-bottom: 8px;
  border-bottom: 1px solid #e9ecef;
  position: relative;
}

.form-section-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 30px;
  height: 2px;
  background: #5273f7;
  border-radius: 2px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  font-size: 15px;
  color: #1d1d1f;
}

.form-label.required::after {
  content: " *";
  color: #ff3b30;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  font-size: 15px;
  background: rgba(255,255,255,0.9);
  transition: all 0.3s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #5273f7;
  box-shadow: 0 0 0 4px rgba(82, 115, 247, 0.1);
  transform: translateY(-1px);
  background: #ffffff;
}

.form-textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.6;
}

/* ------------------ 图片轮播预览 - 增强视觉效果 ------------------ */
.image-carousel {
  position: relative;
  width: 100%;
  height: 200px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(135deg, #f5f6f8 0%, #e9ecef 100%);
  margin-top: 10px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.05);
}

.carousel-container {
  display: flex;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel-item {
  flex: 0 0 100%;
  height: 100%;
  position: relative;
}

.carousel-img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* 轮播图也完整显示 */
  background: #f8f9fb;
}

.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  color: #1d1d1f;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  backdrop-filter: blur(4px);
}

.carousel-nav:hover {
  background: linear-gradient(135deg, #5273f7 0%, #4361ee 100%);
  color: #fff;
  transform: translateY(-50%) scale(1.1);
}

.carousel-prev {
  left: 10px;
}

.carousel-next {
  right: 10px;
}

.carousel-indicators {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}

.carousel-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.carousel-indicator.active {
  background: #5273f7;
  width: 24px;
  border-radius: 4px;
}

/* ------------------ 图片操作工具栏 ------------------ */
.image-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  margin-top: 8px;
}

.image-actions {
  display: flex;
  gap: 8px;
}

.image-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #f5f6f8 0%, #e9ecef 100%);
  color: #6e6e73;
  cursor: pointer;
  transition: all 0.2s ease;
}

.image-action-btn:hover {
  background: linear-gradient(135deg, #5273f7 0%, #4361ee 100%);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(82, 115, 247, 0.2);
}

.image-action-btn.danger:hover {
  background: linear-gradient(135deg, #ff3b30 0%, #ff2d20 100%);
  color: #fff;
}

/* ------------------ 图片放大预览层 ------------------ */
.image-preview-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(8px);
}

.image-preview-overlay.show {
  opacity: 1;
  visibility: visible;
}

.preview-img {
  max-width: 90%;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.image-preview-overlay.show .preview-img {
  transform: scale(1);
}

.preview-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: none;
  font-size: 24px;
  color: #1d1d1f;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.preview-close:hover {
  background: #ff3b30;
  color: #fff;
  transform: rotate(90deg) scale(1.1);
}

/* ------------------ 关系项 ------------------ */
.relation-item {
  background: linear-gradient(135deg, #f9fafb 0%, #f5f6f8 100%);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
  border: 1px solid rgba(255,255,255,0.7);
  transition: all 0.2s ease;
}

.relation-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.relation-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.9);
  border: 1px solid #e5e7eb;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: #ff3b30;
  transition: all 0.2s ease;
}

.relation-remove:hover {
  background: linear-gradient(135deg, #ff3b30 0%, #ff2d20 100%);
  color: #fff;
  transform: scale(1.1);
}

/* ------------------ 设置卡片 ------------------ */
.settings-card {
  background: linear-gradient(180deg, #ffffff 0%, #fefefe 100%);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(255,255,255,0.8);
}

.about {
  text-align: center;
  padding: 20px;
  color: #8e8e93;
  font-size: 14px;
}

/* ------------------ 提示框 - 优化动效 ------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(20px) scale(0.95);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 12px 24px;
  border-radius: 14px;
  font-size: 14px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* ------------------ 分割线 ------------------ */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #e5e7eb, transparent);
  margin: 20px 0;
}

/* ------------------ 星图画布容器 ------------------ */
#graph-canvas {
  width: 100%;
  height: 620px;
  background: linear-gradient(180deg, #ffffff 0%, #fefefe 100%);
  border-radius: 20px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  border: 1px solid rgba(255,255,255,0.8);
  transition: all 0.3s ease;
}

#graph-canvas:hover {
  box-shadow: 0 10px 24px rgba(0,0,0,0.1);
}

/* ------------------ 自定义日期选择器 - 美化 ------------------ */
.date-picker {
  position: relative;
}

.date-picker-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: linear-gradient(180deg, #ffffff 0%, #fefefe 100%);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 16px;
  width: 320px;
  display: none;
  margin-top: 8px;
  border: 1px solid rgba(255,255,255,0.9);
  transform: translateY(10px) scale(0.98);
  transition: all 0.2s ease;
}

.date-picker-panel.show {
  display: block;
  transform: translateY(0) scale(1);
}

.date-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.date-picker-btn {
  background: linear-gradient(135deg, #f5f6f8 0%, #e9ecef 100%);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.date-picker-btn:hover {
  background: linear-gradient(135deg, #5273f7 0%, #4361ee 100%);
  color: #fff;
  transform: scale(1.1);
}

.date-picker-month {
  font-size: 16px;
  font-weight: 600;
  color: #1d1d1f;
}

.date-picker-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 8px;
}

.date-picker-week div {
  font-size: 13px;
  color: #8e8e93;
  padding: 6px 0;
}

.date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.date-picker-day {
  text-align: center;
  padding: 8px 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  position: relative;
}

.date-picker-day:hover {
  background: #f0f5ff;
  color: #5273f7;
  transform: scale(1.1);
}

.date-picker-day.active {
  background: linear-gradient(135deg, #5273f7 0%, #4361ee 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(82, 115, 247, 0.3);
}

.date-picker-day.other-month {
  color: #ccc;
  pointer-events: none;
}

/* ------------------ 确认删除弹窗 ------------------ */
.confirm-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(4px);
}

.confirm-modal.show {
  opacity: 1;
  visibility: visible;
}

.confirm-box {
  background: linear-gradient(180deg, #ffffff 0%, #fefefe 100%);
  border-radius: 20px;
  width: 90%;
  max-width: 400px;
  padding: 24px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  transform: translateY(20px) scale(0.98);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255,255,255,0.9);
}

.confirm-modal.show .confirm-box {
  transform: translateY(0) scale(1);
}

.confirm-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
}

.confirm-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

/* ------------------ 动画定义 ------------------ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ------------------ 响应式优化 ------------------ */
@media (max-width: 1000px) {
  .card-grid {
    column-count: 2; /* 平板端2列 */
  }
}

@media (max-width: 640px) {
  .card-grid {
    column-count: 1; /* 手机端1列 */
  }
  
  /* 手机端卡片间距稍微缩小 */
  .card {
    margin-bottom: 16px;
  }
  
  .card-grid {
    column-gap: 16px;
  }
  
  .tab-item {
    font-size: 14px;
    padding: 10px 6px;
  }
  
  .page-header h2 {
    font-size: 20px;
  }
  
  .card-img-empty {
    min-height: 160px;
  }
  
  #graph-canvas {
    height: 400px;
  }
}

/* ------------------ 平面化二级菜单 ------------------ */
.card-menu {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 10;
}
.menu-trigger {
  width: 32px;
  height: 32px;
  border: none;
  background: #fff;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  color: #6e6e73;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  transition: all 0.2s;
}
.menu-trigger:hover { background: #f5f6f8; color: #1d1d1f; }
.menu-panel {
  position: absolute;
  right: 0;
  bottom: 40px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 8px 0;
  min-width: 120px;
  display: none;
  z-index: 20;
}
.menu-panel.show { display: block; opacity: 1; transition: opacity 0.2s ease; }
.menu-item {
  padding: 10px 16px;
  font-size: 14px;
  color: #1d1d1f;
  cursor: pointer;
  transition: background 0.2s;
}
.menu-item:hover { background: #f5f6f8; }
.menu-item-danger { color: #ff3b30; }
.menu-item-danger:hover { background: #fff5f5; }

/* ------------------ 平面化详情弹窗 ------------------ */
.detail-modal-box { max-width: 800px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.detail-item { display: flex; flex-direction: column; gap: 6px; }
.detail-item-full { grid-column: 1 / -1; }
.detail-label { font-size: 14px; font-weight: 500; color: #6e6e73; }
.detail-value {
  font-size: 15px;
  color: #1d1d1f;
  line-height: 1.6;
  padding: 10px 0;
  border-bottom: 1px solid #f5f6f8;
}
.detail-images { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.detail-img { max-width: 200px; max-height: 200px; border-radius: 8px; object-fit: contain; background: #f8f9fb; }
.detail-relations { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.relation-tag { padding: 6px 12px; background: #f5f6f8; border-radius: 8px; font-size: 14px; }
.detail-chars { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.char-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f5f6f8;
  border-radius: 12px;
  font-size: 14px;
}
.char-tag-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }

/* ------------------ 隐藏原卡片按钮 ------------------ */
.card-delete, .card-graph { display: none !important; }

/* --- 1. 基礎模態框樣式（適配你現有的類名） --- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: modalFadeIn 0.3s ease;
}
.modal.show { /* 你原本的 JS 是加 .show 類，這裡保留 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}
.modal-box {
  width: 100%;
  max-width: 1000px;
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideUp 0.3s ease;
  display: flex;
  flex-direction: column;
  position: relative; /* 新增：讓子元素的 absolute 定位以此為基準 */
}

.modal-header {
  position: absolute; /* 改為絕對定位，浮在內容上方 */
  top: 0;
  left: 0;
  right: 0;
  z-index: 20; /* 保證在最上層 */
  padding: 16px 24px;
  background: transparent; 
  border-bottom: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #303133; /* 預設顏色，有 Banner 時 JS 會動態改成白色 */
  transition: color 0.3s ease;
}
.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  color: #606266; /* 預設顏色，有 Banner 時 JS 會動態改成白色 */
  font-size: 24px;
  line-height: 36px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.1);
}
.modal-body {
  padding: 0; /* 先設為0，內部區塊自己控制 padding */
  overflow-y: auto;
  flex: 1;
}

/* --- 2. 新增：頂部設計圖 Banner 樣式 --- */
.detail-banner-wrapper {
  position: relative;
  margin-top: -68px; /* 向上移動，覆蓋原本的 Header 區域，讓 Header 浮在 Banner 上 */
  padding-top: 0px; /* 撐開高度，避免內容被 Header 擋住 */
}
.detail-banner {
  width: 100%;
  position: relative;
  overflow: hidden;
  padding-top: 0px; 
}

.banner-scroll {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.banner-scroll::-webkit-scrollbar {
  display: none;
}
.banner-img {
  width: 100%;
  /* 移除之前的 padding-top 造成的多餘空間，把圖片往上移填滿 */
  margin-top: -68px; 
  display: block;
  max-height: 600px;
  height: auto;
  object-fit: contain;
}

/* Banner 底部漸變遮罩 */
.banner-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 60%;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
  pointer-events: none;
}

/* --- 3. 新增：內容區域樣式 --- */
.detail-content-inner {
  padding: 24px;
}

/* 核心資訊卡片 */
.core-info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.info-card {
  background: #f5f7fa;
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  transition: all 0.2s ease;
}
.info-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.info-label {
  font-size: 13px;
  color: #909399;
  margin-bottom: 6px;
}
.info-value {
  font-size: 18px;
  font-weight: 600;
  color: #303133;
  line-height: 1.2;
}

/* 長文本模組 */
.detail-section {
  margin-bottom: 24px;
}
.section-label {
  font-size: 16px;
  font-weight: 700;
  color: #303133;
  margin-bottom: 10px;
  padding-left: 8px;
  border-left: 4px solid #409eff;
}
.section-content {
  background: #fafafa;
  border-radius: 8px;
  padding: 16px;
  line-height: 1.7;
  color: #606266;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 角色圖片畫廊 */
.detail-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.gallery-img {
  width: 100%;
  height: 180px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  transition: all 0.3s ease;
}
.gallery-img:hover {
  transform: scale(1.03);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

/* 人物關係標籤 */
.relation-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.relation-tag {
  background: #ecf5ff;
  color: #409eff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  border: 1px solid #b3d8ff;
  transition: all 0.2s ease;
}
.relation-tag:hover {
  background: #409eff;
  color: #fff;
}

/* --- 4. 響應式適配 --- */
@media (max-width: 768px) {
  .modal.show { padding: 10px; }
  .banner-img { max-height: 280px; }
  .detail-content-inner { padding: 16px; }
  .core-info-grid { grid-template-columns: repeat(2, 1fr); margin-bottom: 24px; }
  .detail-gallery { grid-template-columns: repeat(2, 1fr); }
  .info-value { font-size: 16px; }
}

/* --- 5. 動畫定義 --- */
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalSlideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* 图片画廊容器 */
.detail-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* 自适应网格 */
  gap: 12px;
  margin-top: 12px;
}

/* 图片项 */
.gallery-item {
  width: 100%;
  aspect-ratio: 3/4; /* 固定宽高比（可选，根据需求调整） */
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* 画廊图片 */
.gallery-img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* 裁剪填充 */
  display: block;
}

/* 分区标题 */
.section-label {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  margin-bottom: 8px;
  padding-left: 4px;
  border-left: 3px solid #5273f7;
}

/* 详情页 Header 基础样式 */
.detail-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.3s ease;
}

/* 有 Banner 时：Header 透明 */
.detail-header.has-banner {
  background: transparent;
}

/* 无 Banner 时：Header 白色 + 底部分割线 */
.detail-header.no-banner {
  background: #fff;
  border-bottom: 1px solid #eee;
}

/* 关闭按钮默认样式（无 Banner 时） */
#detail-close {
  background: #f5f5f5;
  color: #303133;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  transition: background 0.2s ease;
}

#detail-close:hover {
  background: #eee;
}
