/* ==========================================
   布局：底部Tab导航、页面容器
   ========================================== */

/* ---- App 根容器 ---- */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
}

/* ---- 视图容器（排除Tab） ---- */
#view-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: none;
  flex-direction: column;
}

.view.active {
  display: flex;
}

/* ---- 底部 Tab 导航 ---- */
#tab-bar {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0,0,0,0.06);
  display: flex;
  height: calc(var(--tab-height) + var(--tab-safe-area));
  padding-bottom: var(--tab-safe-area);
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.tab-item .tab-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform var(--transition-fast);
}

.tab-item .tab-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.tab-item.active .tab-icon {
  transform: scale(1.15) translateY(-2px);
}

.tab-item.active .tab-label {
  color: var(--primary);
}

.tab-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}

/* ---- 视图页面通用 ---- */
.view-header {
  padding: var(--space-md) var(--space-md) 0;
  flex-shrink: 0;
}

.view-content {
  flex: 1;
  padding: var(--space-md);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- 渐变顶部区域 ---- */
.gradient-header {
  background: var(--bg-primary);
  padding: var(--space-md);
  color: #FFF;
  flex-shrink: 0;
}

.gradient-header.achievement {
  background: var(--bg-achievement);
}

.gradient-header.settings {
  background: var(--bg-settings);
}

/* ---- 引导页 ---- */
#onboarding-view {
  background: var(--bg-primary);
  z-index: 200;
}

/* ---- 遮罩层 ---- */
#modal-container {
  position: fixed;
  inset: 0;
  z-index: 500;
  pointer-events: none;
}

#modal-container .modal-overlay.active {
  pointer-events: all;
}

/* ---- 反馈条层 ---- */
#feedback-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1500;
  pointer-events: none;
  display: flex;
  justify-content: center;
  padding-top: calc(var(--space-md) + env(safe-area-inset-top, 0px));
}

/* iOS 安全区 */
.safe-top {
  padding-top: env(safe-area-inset-top, 12px);
}
