/* ===== 生命地图 公共样式 v3.0（统一类名体系）===== */
:root {
  --bg-main: #FAF3ED;
  --bg-card: #FFFFFF;
  --primary-brown: #7A4B22;
  --primary-brown-light: #B07A48;
  --primary-purple: #8B6FD4;
  --primary-purple-light: #C4B0F0;
  --primary-purple-bg: #F0ECFB;
  --accent-pink: #F48FB1;
  --sidebar-width: 200px;
  --bottom-nav-height: 56px;
  --topbar-height: 50px;
  --card-radius: 16px;
  --card-shadow: 0 2px 16px rgba(122,75,34,0.08);
  --font-main: 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* 五行色 */
  --wuxing-jin: #E8A427;
  --wuxing-mu: #4CAF50;
  --wuxing-shui: #2196F3;
  --wuxing-huo: #F44336;
  --wuxing-tu: #9C6B30;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg-main);
  color: #333;
  min-height: 100vh;
  display: flex;
}

/* ===== 侧边导航 ===== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: #fff;
  border-right: 1px solid #EFE8DF;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid #EFE8DF;
  text-decoration: none;
}

/* Logo 图标（绿色太极圆）*/
.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #2E7D32, #66BB6A);
  flex-shrink: 0;
}

/* Logo 文字 */
.sidebar-logo-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
  font-weight: 700;
  color: #3A2A1A;
}

.sidebar-nav {
  padding: 12px 0 8px;
}

.nav-section-title {
  font-size: 11px;
  color: #B0A090;
  padding: 8px 16px 6px;
  letter-spacing: 0.5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  color: #7C6B5E;
  text-decoration: none;
  border-radius: 10px;
  margin: 2px 8px;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  background: #F0ECFB;
  color: #8B6FD4;
}

.nav-item.active {
  background: #F0ECFB;
  color: #8B6FD4;
  font-weight: 600;
}

.nav-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-text {
  flex: 1;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: #F44336;
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
}

/* 兼容旧 logo-icon / logo-text 类（供其他页面可能引用）*/
.logo-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-char {
  color: #fff;
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
  font-weight: 700;
}
.logo-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
  font-weight: 700;
  color: #3A2A1A;
  letter-spacing: 1px;
}

.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid #EFE8DF;
}

.nav-section {
  padding: 12px 0 4px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid #EFE8DF;
}

.download-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--primary-purple-bg);
  color: var(--primary-purple);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
}

.download-btn:hover { background: var(--primary-purple-light); color: #fff; }

/* ===== 主内容区 ===== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  padding: 24px 40px 40px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* ===== 右侧工具栏 ===== */
.right-toolbar {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 99;
}

.toolbar-btn {
  width: 40px; height: 40px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  cursor: pointer;
  border: none;
  transition: transform 0.2s, box-shadow 0.2s;
  color: #8B6FD4;
}

.toolbar-btn:hover { transform: scale(1.1); box-shadow: 0 4px 16px rgba(0,0,0,0.15); }

.fab-btn {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #F48FB1, #CE93D8);
  border-radius: 50%;
  box-shadow: 0 3px 12px rgba(244,143,177,0.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  cursor: pointer;
  border: none;
  color: #fff;
  transition: transform 0.2s;
}

.fab-btn:hover { transform: scale(1.1); }

/* ===== 通用卡片 ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: #3A2A1A;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  display: inline-block;
  width: 4px; height: 18px;
  background: linear-gradient(to bottom, #8B6FD4, #B07A48);
  border-radius: 2px;
}

/* ===== Tab 切换 ===== */
.tab-group {
  display: flex;
  gap: 4px;
  background: #F5EFEB;
  border-radius: 24px;
  padding: 4px;
  margin-bottom: 16px;
  width: fit-content;
}

.tab-btn {
  padding: 7px 18px;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: #8C7060;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-main);
}

.tab-btn.active {
  background: var(--primary-brown);
  color: #fff;
  box-shadow: 0 2px 8px rgba(122,75,34,0.25);
}

.tab-btn:hover:not(.active) {
  background: #E8D8CC;
  color: var(--primary-brown);
}

/* ===== 胶囊标签 ===== */
.tag-capsule {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  background: var(--primary-purple-bg);
  color: var(--primary-purple);
}

/* ===== 页面标题栏 ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #F0E8DE;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: #3A2A1A;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title .title-emoji {
  font-size: 24px;
}

/* ===== 按钮 ===== */
.btn-primary {
  background: linear-gradient(135deg, #8B6FD4, #6A4FC0);
  color: #fff;
  border: none;
  border-radius: 22px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  font-family: var(--font-main);
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-brown {
  background: linear-gradient(135deg, #7A4B22, #B07A48);
  color: #fff;
  border: none;
  border-radius: 22px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  font-family: var(--font-main);
}

.btn-brown:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--primary-purple);
  border: 1.5px solid var(--primary-purple-light);
  border-radius: 22px;
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-main);
}

.btn-ghost:hover { background: var(--primary-purple-bg); }

/* ===== 输入框 ===== */
.input-field {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #E8D8CC;
  border-radius: 10px;
  font-size: 14px;
  color: #3A2A1A;
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--font-main);
}

.input-field:focus { border-color: var(--primary-purple-light); }

.input-group {
  margin-bottom: 14px;
}

.input-label {
  font-size: 13px;
  color: #8C7060;
  margin-bottom: 5px;
  font-weight: 500;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #B0A090;
}

.empty-icon { font-size: 52px; margin-bottom: 12px; }
.empty-text { font-size: 15px; margin-bottom: 16px; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: #D0C0B0; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 新建排盘按钮 ===== */
.new-calc-btn {
  margin: 12px 12px 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #8B6FD4, #6A4FC0);
  border-radius: 12px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
  text-decoration: none;
}
.new-calc-btn:hover { opacity: 0.9; }
.new-calc-btn i { font-size: 14px; }

/* ===== 侧边栏底部导航 ===== */
.sidebar-bottom-nav {
  margin-top: auto;
  padding-bottom: 16px;
}

/* ===== 更多菜单图标 ===== */
.mm-icon i {
  font-size: 20px;
  color: #fff;
}

/* ===== 导航容器（由 nav.js 注入）===== */
#nav-container {
  flex-shrink: 0;
}

#mobile-topbar-container,
#bottom-nav-container {
  display: none;
}

/* ===== 响应式：平板 ===== */
@media (max-width: 900px) {
  .sidebar {
    width: 60px;
    overflow: visible;
  }
  .sidebar-logo-text,
  .nav-section-title,
  .nav-text,
  .download-btns,
  .new-calc-btn span,
  .sidebar-bottom-nav { display: none; }
  .sidebar-logo { justify-content: center; padding: 14px 8px; }
  .sidebar-logo-icon {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 32px !important;
    height: 32px !important;
    margin: 0 auto !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #2E7D32, #66BB6A) !important;
  }
  .new-calc-btn { justify-content: center; padding: 10px; }
  .main-wrapper { margin-left: 60px; }
  .main-content { padding: 16px 16px 32px; }
  .nav-item { justify-content: center; padding: 12px 8px; margin: 2px 4px; }
  .nav-icon { font-size: 20px; width: auto; }
  .right-toolbar { right: 4px; }
}

/* ===== 响应式：手机端 ===== */
@media (max-width: 640px) {
  /* 隐藏侧边栏，改用底部/顶部导航 */
  .sidebar { display: none !important; }
  .right-toolbar { display: none !important; }

  /* 显示手机端导航容器 */
  #mobile-topbar-container,
  #bottom-nav-container {
    display: block !important;
  }

  /* 覆盖 body 的 flex 布局，使元素垂直排列 */
  body {
    display: block !important;
  }

  /* 主内容撑满 */
  .main-wrapper {
    margin-left: 0;
    padding-top: var(--topbar-height);
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 14px);
  }

  .main-content {
    padding: 14px !important;
    max-width: 100% !important;
  }

  /* 卡片 */
  .card { padding: 14px 14px; border-radius: 14px; }
  .card-title { font-size: 15px; }

  /* 页头 */
  .page-header { margin-bottom: 14px; padding-bottom: 12px; }
  .page-title { font-size: 18px; }
  .page-title .title-emoji { font-size: 20px; }

  /* Tab */
  .tab-group { width: 100%; overflow-x: auto; }
  .tab-btn { padding: 6px 14px; font-size: 13px; white-space: nowrap; }

  /* 按钮 */
  .btn-primary, .btn-brown { padding: 9px 18px; font-size: 13px; }
  .btn-ghost { padding: 8px 16px; font-size: 13px; }

  /* 输入框 */
  .input-field { font-size: 16px; /* 防 iOS 缩放 */ padding: 11px 13px; }

  /* 表单两列→单列 */
  .form-row { grid-template-columns: 1fr !important; flex-direction: column; }
  .two-person-grid { grid-template-columns: 1fr !important; }

  /* 通用工具类 */
  .hide-mobile { display: none !important; }
  .show-mobile { display: block !important; }
  .show-mobile-flex { display: flex !important; }
  .mobile-single-col { grid-template-columns: 1fr !important; }
}

/* ===== 底部导航栏（手机专属）===== */
.bottom-nav {
  display: none;
}

@media (max-width: 640px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    padding-bottom: var(--safe-bottom);
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid #EFE8DF;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    align-items: center;
    justify-content: space-around;
    padding-left: 8px;
    padding-right: 8px;
    box-shadow: 0 -2px 10px rgba(122, 75, 34, 0.06);
    box-sizing: border-box;
  }

  .bn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    padding: 4px 12px;
    text-decoration: none;
    transition: background 0.2s;
    flex: 1;
    min-width: 0;
  }

  .bn-item:active { background: var(--primary-purple-bg); }

  .bn-icon {
    font-size: 20px;
    line-height: 1;
    color: #B0A090;
  }

  .bn-label {
    font-size: 10px;
    color: #B0A090;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
  }

  .bn-item.active .bn-label { color: var(--primary-purple); font-weight: 700; }
  .bn-item.active .bn-icon { color: var(--primary-purple); }

  /* 中央大按钮 */
  .bn-center {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, #8B6FD4, #6A4FC0);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 16px rgba(139,111,212,0.45);
    flex-shrink: 0;
    cursor: pointer;
    margin-top: -14px;
    border: 3px solid #fff;
    text-decoration: none;
  }
}

/* ===== 更多菜单覆层（仅移动端）===== */
.more-menu-overlay,
.more-menu-sheet {
  display: none;
}

@media (max-width: 640px) {
  .more-menu-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 198;
    backdrop-filter: blur(4px);
  }

  .more-menu-overlay.open { display: block; }

  .more-menu-sheet {
    display: block;
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
    left: 0; right: 0;
    background: #fff;
    border-radius: 24px 24px 0 0;
    padding: 16px 16px 8px;
    z-index: 199;
    animation: slideUpMenu 0.28s ease;
  }

  .more-menu-sheet.open { display: block; }

  @keyframes slideUpMenu {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .more-menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 8px;
  }

  .mm-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 4px;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
  }

  .mm-item:active { background: var(--primary-purple-bg); }

  .mm-item .mm-icon {
    width: 44px; height: 44px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
  }

  .mm-item .mm-label { font-size: 11px; color: #5A3A1A; font-weight: 500; text-align: center; }
}

/* ===== 移动端顶部导航条 ===== */
.mobile-topbar {
  display: none;
}

@media (max-width: 640px) {
  .mobile-topbar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(250,243,237,0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    border-bottom: 1px solid rgba(240,232,222,0.8);
    box-sizing: border-box;
  }

  .topbar-logo {
    width: 80px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
  }

  .tl-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2E7D32, #66BB6A);
    flex-shrink: 0;
  }

  .topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: #7C6B5E;
  }

  .topbar-actions {
    width: 80px;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
  }

  .topbar-action-btn {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: #fff;
    border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  }
}
