/* ==========================================================================
   main.css — 全局布局与页面样式
   移动端优先响应式：max-width 480px 居中，中式对称布局，大量留白
   ========================================================================== */

/* ---------- 应用骨架容器 ---------- */
.app-shell {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(72px + var(--safe-bottom));
}

/* ---------- 顶部导航栏 ---------- */
.nav-top {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(13, 13, 18, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-ink);
}

.nav-top__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-kai);
  font-size: 1.15rem;
  color: var(--text-gold);
  letter-spacing: 2px;
}

.nav-top__brand .logo-mark {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  overflow: hidden;
  flex: none;
}
.nav-top__brand .logo-mark img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.nav-top__actions { display: flex; align-items: center; gap: 14px; }

.nav-top__link {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.25s var(--ease-ink);
}
.nav-top__link:hover { color: var(--text-jade); }

.nav-top__avatar {
  width: 32px; height: 32px;
  border-radius: 4px;
  border: 1px solid var(--border-gold);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.8rem; color: var(--text-gold);
}

/* ---------- 主内容区 ---------- */
.page {
  flex: 1;
  padding: 20px 18px;
  animation: fade-in 0.5s var(--ease-ink);
}

.page--center {
  display: flex; flex-direction: column; align-items: center;
}

/* 页面标题 — 书法感 */
.page-title {
  font-family: var(--font-kai);
  font-size: 1.5rem;
  color: var(--text-gold);
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: 3px;
}

.page-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin-bottom: 20px;
  letter-spacing: 1px;
}

/* ---------- 卡片网格 ---------- */
.grid {
  display: grid;
  gap: 14px;
}
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 360px) {
  .grid--3 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 页面切换动画 ---------- */
.page-enter { animation: float-up 0.5s var(--ease-ink) both; }

/* ---------- 加载动画（水墨晕染） ---------- */
.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 18, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.loader-overlay.is-active { display: flex; }

.ink-loader {
  position: relative;
  width: 64px; height: 64px;
}
.ink-loader__ring {
  position: absolute; inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--jade);
  border-right-color: var(--gold);
  border-radius: 50%;
  animation: ink-rotate 1.2s linear infinite;
}
.ink-loader__ripple {
  position: absolute; inset: 0;
  border: 1px solid var(--jade);
  border-radius: 50%;
  animation: ink-spread 1.8s ease-out infinite;
}
.ink-loader__ripple:nth-child(2) { animation-delay: 0.6s; }
.ink-loader__ripple:nth-child(3) { animation-delay: 1.2s; }
.ink-loader__text {
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  margin-top: 14px;
  font-size: 0.78rem;
  font-family: var(--font-kai);
  color: var(--text-secondary);
  white-space: nowrap;
  letter-spacing: 2px;
}

/* ---------- 弹窗 / 模态框 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 0;
}
.modal-overlay.is-active { display: flex; animation: fade-in 0.3s var(--ease-ink); }

.modal {
  width: 100%;
  max-width: var(--container-max);
  background: var(--bg-ink);
  border: 1px solid var(--border-gold);
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  position: relative;
  animation: float-up 0.3s var(--ease-ink);
}
.modal__handle {
  width: 36px; height: 3px;
  background: var(--border-gold);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.modal__title {
  font-family: var(--font-kai);
  font-size: 1.2rem;
  color: var(--text-gold);
  text-align: center;
  margin-bottom: 16px;
  letter-spacing: 2px;
}
.modal__close {
  position: absolute;
  top: 14px; right: 16px;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  background: var(--bg-ink-deep);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  border: 1px solid var(--border-ink);
  transition: all 0.25s var(--ease-ink);
}
.modal__close:hover { color: var(--text-cinnabar); border-color: var(--cinnabar); }

/* 居中弹窗变体 */
.modal--center {
  align-items: center;
  border-radius: var(--radius-xl);
  border-bottom: 1px solid var(--border-gold);
}
.modal-overlay.modal--center-wrap { align-items: center; }

/* ---------- Toast 提示 ---------- */
.toast-container {
  position: fixed;
  top: 70px; left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 360px;
}
.toast {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  text-align: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: float-up 0.3s var(--ease-ink);
  pointer-events: auto;
  letter-spacing: 1px;
}
.toast--info {
  background: rgba(21, 21, 30, 0.92);
  border: 1px solid var(--border-ink);
  color: var(--text-primary);
}
.toast--success {
  background: rgba(74, 124, 126, 0.15);
  border: 1px solid var(--jade);
  color: var(--text-jade);
}
.toast--warn {
  background: rgba(138, 122, 74, 0.15);
  border: 1px solid var(--gold);
  color: var(--text-gold);
}
.toast--error {
  background: rgba(139, 58, 58, 0.18);
  border: 1px solid var(--cinnabar);
  color: var(--text-cinnabar);
}

/* ---------- 底部固定免责声明栏 ---------- */
.disclaimer-bar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--container-max);
  z-index: 40;
  padding: 8px 16px calc(8px + var(--safe-bottom));
  background: rgba(13, 13, 18, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-ink);
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.5;
  letter-spacing: 0.5px;
}
.disclaimer-bar .warn-icon { color: var(--cinnabar); }

/* ---------- 底部导航（末法世界用） ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--container-max);
  z-index: 45;
  display: none;
  justify-content: space-around;
  padding: 6px 0 calc(6px + var(--safe-bottom));
  background: rgba(13, 13, 18, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-ink);
}
.tabbar.is-active { display: flex; }
.tabbar__item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 4px 0;
  min-height: 44px;
  transition: color 0.25s var(--ease-ink);
}
.tabbar__item.is-active { color: var(--text-jade); }
.tabbar__icon { font-size: 1.1rem; }

/* 有 tabbar 时调整 app 底部留白 */
.app-shell:has(.tabbar.is-active) { padding-bottom: calc(64px + var(--safe-bottom)); }

/* ---------- 工具类 ---------- */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { flex-direction: column; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
