/* ========================================
   全局样式 · 模拟 UI.md 中的设计令牌
   ======================================== */

:root {
  /* 主色调 */
  --color-primary: #f84a1e;
  --color-primary-light: #ff6815;
  --color-primary-dark: #e04015;
  --color-primary-muted: #fff0eb;

  /* 强调色 */
  --color-accent-blue: #3b82f6;
  --color-accent-green: #10b981;
  --color-accent-yellow: #f59e0b;
  --color-accent-red: #ef4444;

  /* 中性色 */
  --color-bg-page: #f4f6f9;
  --color-bg-card: #ffffff;
  --color-bg-hover: #fafbfc;
  --color-border-light: #f3f4f6;
  --color-border-default: #e5e7eb;

  /* 文字 */
  --color-text-primary: #111827;
  --color-text-secondary: #6b7280;
  --color-text-tertiary: #9ca3af;
  --color-text-inverse: #ffffff;

  /* 阴影 */
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.03);
  --shadow-elevated: 0 4px 20px rgba(0, 0, 0, 0.05);
  --shadow-button: 0 2px 10px rgba(248, 74, 30, 0.2);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.1);

  /* 动画 */
  --animate-pulse-slow: pulse-slow 3s ease-in-out infinite;
  --animate-pulse-fast: pulse-fast 0.8s ease-in-out infinite;
}

/* 基础重置 */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.5;
  color: #111827;
  color: var(--color-text-primary);
  background: #f4f6f9;
  background: var(--color-bg-page);
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

/* 移动端预览容器 */
.app-shell {
  max-width: 448px;
  margin: 0 auto;
  background: var(--color-bg-page);
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.05);
}

/* 顶部 Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-light);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 16px;
  box-shadow: var(--shadow-button);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-primary);
}

.brand-sub {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--color-bg-hover);
}

.icon-btn .badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--color-accent-red);
  color: white;
  font-size: 10px;
  font-weight: bold;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-primary-light);
  overflow: hidden;
  background: var(--color-primary-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  font-weight: bold;
  cursor: pointer;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 主内容区 */
.app-main {
  padding-bottom: 80px;
}

/* 底部 Tab 导航 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 448px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 16px));
  z-index: 50;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  text-decoration: none;
  color: var(--color-text-tertiary);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.2s;
  position: relative;
}

.bottom-nav-item.active {
  color: var(--color-primary);
}

.bottom-nav-item .nav-icon-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav-item.active .nav-icon-wrap::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 9999px;
  background: var(--color-primary);
  opacity: 0.15;
}

.bottom-nav-item.active .nav-icon-wrap svg {
  color: var(--color-primary);
  fill: var(--color-primary-muted);
  stroke-width: 2.5;
}

.bottom-nav-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* 通用按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  box-shadow: var(--shadow-button);
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-outline {
  background: white;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn-outline:hover {
  background: var(--color-primary-muted);
}

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

.btn-danger {
  background: var(--color-accent-red);
  color: white;
}

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

.btn-lg {
  padding: 12px 20px;
  font-size: 17px;
  font-weight: 700;
}

.btn-block {
  width: 100%;
}

/* 卡片 */
.card {
  background: var(--color-bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}

.card-padded {
  padding: 16px;
}

.card-flat {
  background: var(--color-bg-card);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--color-border-light);
}

/* 区块标题 */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  margin: 24px 0 12px;
}

.section-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.section-title-left::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--color-primary);
  border-radius: 2px;
}

.section-title-action {
  font-size: 13px;
  color: var(--color-text-secondary);
  text-decoration: none;
}

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 6px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 空状态 */
.empty-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--color-text-tertiary);
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.4;
  margin-bottom: 8px;
}

.empty-state-title {
  font-size: 15px;
  color: var(--color-text-primary);
  font-weight: 500;
  margin-bottom: 4px;
}

.empty-state-desc {
  font-size: 13px;
}

/* 通用工具类 */
.text-primary { color: var(--color-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-inverse { color: var(--color-text-inverse); }
.text-accent-green { color: var(--color-accent-green); }
.text-accent-red { color: var(--color-accent-red); }
.text-accent-yellow { color: var(--color-accent-yellow); }
.text-accent-blue { color: var(--color-accent-blue); }

.bg-card { background: var(--color-bg-card); }
.bg-page { background: var(--color-bg-page); }
.bg-hover { background: var(--color-bg-hover); }
.bg-primary { background: var(--color-primary); }
.bg-primary-muted { background: var(--color-primary-muted); }

.text-xs { font-size: 12px; }
.text-sm { font-size: 13px; }
.text-base { font-size: 15px; }
.text-lg { font-size: 17px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 22px; }

.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }

.rounded-md { border-radius: 8px; }
.rounded-lg { border-radius: 12px; }
.rounded-xl { border-radius: 16px; }
.rounded-2xl { border-radius: 20px; }
.rounded-full { border-radius: 9999px; }

.shadow-card { box-shadow: var(--shadow-card); }
.shadow-elevated { box-shadow: var(--shadow-elevated); }
.shadow-button { box-shadow: var(--shadow-button); }

.px-4 { padding-left: 16px; padding-right: 16px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 20px; }

.mx-4 { margin-left: 16px; margin-right: 16px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

.flex-1 { flex: 1; }
.text-center { text-align: center; }

/* 动画 */
@keyframes pulse-slow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes pulse-fast {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes ripple {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.animate-pulse-slow {
  animation: pulse-slow 3s ease-in-out infinite;
}

/* Tag 徽章 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-primary {
  background: var(--color-primary);
  color: white;
}

.tag-primary-muted {
  background: var(--color-primary-muted);
  color: var(--color-primary);
}

.tag-green {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-accent-green);
}

.tag-red {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-accent-red);
}

.tag-yellow {
  background: rgba(245, 158, 11, 0.1);
  color: var(--color-accent-yellow);
}

.tag-blue {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-accent-blue);
}

.tag-gray {
  background: var(--color-bg-hover);
  color: var(--color-text-secondary);
}

/* 滚动容器 */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
  overflow-x: auto;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* 弹窗遮罩 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-mask.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 20px;
  width: 280px;
  max-width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-elevated);
  text-align: center;
  animation: modal-in 0.2s ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Tab 栏 */
.tab-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px 0;
  position: sticky;
  top: 0;
  background: var(--color-bg-page);
  z-index: 40;
  border-bottom: 1px solid var(--color-border-light);
}

.tab-item {
  position: relative;
  padding: 0 0 12px;
  font-size: 16px;
  color: var(--color-text-secondary);
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.2s;
}

.tab-item.active {
  color: var(--color-primary);
  font-weight: 700;
}

.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
  border-radius: 3px;
}

/* 分类筛选 */
.filter-bar {
  display: flex;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border-light);
  height: 48px;
}

.filter-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 14px;
  color: var(--color-text-secondary);
  cursor: pointer;
  background: none;
  border: none;
}

.filter-item.active {
  color: var(--color-primary);
  font-weight: 500;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 200;
  display: none;
  box-shadow: var(--shadow-elevated);
  max-width: 80%;
  text-align: center;
}

.toast.show {
  display: block;
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* 列表项 */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
  background: white;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:active {
  background: var(--color-bg-hover);
}

/* 链接 hover 效果 */
a {
  color: inherit;
  text-decoration: none;
}

/* 移动端响应 */
@media (max-width: 480px) {
  .app-shell {
    max-width: 100%;
    box-shadow: none;
  }
}
