* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #0F6E56;
  --primary-light: #E8F5F0;
  --primary-dark: #085041;
  --bg: #F5F5F0;
  --bg-card: #ffffff;
  --text-dark: #333333;
  --text-body: #444444;
  --text-light: #666666;
  --text-muted: #999990;
  --text-placeholder: #BBBBAA;
  --border: #F0F0EB;
  --tag-bg: #F0F0EB;
  --vip-color: #B8860B;
  --vip-bg: #FFF8E1;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-full: 50px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.6;
  height: 100%;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* Desktop: content area max-width with centered padding */
@media (min-width: 768px) {
  :root {
    --content-max: 720px;
    --radius-lg: 20px;
  }
  html, body {
    font-size: 15px;
  }
}
@media (min-width: 1200px) {
  :root {
    --content-max: 960px;
  }
  html, body {
    font-size: 16px;
  }
}

#pages-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.page {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.page-overlay {
  z-index: 100;
  background: var(--bg-card);
}

/* Tab Bar */
.tab-bar {
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 6px 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  color: #999999;
  font-size: 10px;
  transition: color 0.2s;
}

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

.tab-icon {
  width: 24px;
  height: 24px;
}

.tab-icon svg {
  width: 100%;
  height: 100%;
}

/* Common Components */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

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

.tag-active {
  background: var(--primary);
  color: #ffffff;
}

.capsule {
  padding: 7px 16px;
  border-radius: 18px;
  font-size: 13px;
  background: var(--tag-bg);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}

.capsule.active {
  background: var(--primary);
  color: #ffffff;
}

/* Scrollbar hidden */
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

/* Toast notification */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

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

/* Loading overlay */
.loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #f0f0eb 25%, #e8e8e3 50%, #f0f0eb 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

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

.skeleton-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 10px;
}

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-line-short { width: 60%; }
.skeleton-line-long { width: 90%; }
.skeleton-line-medium { width: 75%; }

/* Error state */
.error-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.error-state-icon { font-size: 40px; display: block; margin-bottom: 10px; }
.error-state-text { font-size: 14px; margin-bottom: 12px; }
.error-retry-btn {
  display: inline-block;
  padding: 8px 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
}

/* Search Page */
#page-search { background: var(--bg); }

.search-page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-card);
}

.search-page-bar {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 20px;
  padding: 8px 12px;
}

.sp-icon { font-size: 14px; margin-right: 6px; }

.sp-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  color: var(--text-dark);
}

.sp-input::placeholder { color: var(--text-placeholder); }

.sp-clear {
  width: 18px; height: 18px; border-radius: 50%;
  background: #ccc; color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

.sp-cancel { color: var(--primary); font-size: 14px; cursor: pointer; white-space: nowrap; }

.hot-section { padding: 20px 16px; }
.hot-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.hot-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.hot-tag {
  padding: 6px 14px; background: var(--bg-card); border-radius: 16px;
  font-size: 13px; color: var(--text-light); cursor: pointer;
}
.hot-tag:active { background: var(--primary-light); color: var(--primary); }

.search-results { padding: 12px 16px; }
.search-count { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.search-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 14px; }

.search-result-item {
  background: var(--bg-card); border-radius: 12px; padding: 14px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.search-result-item:active { transform: scale(0.98); }

.sr-body { flex: 1; margin-right: 10px; }
.sr-tag { font-size: 11px; color: var(--primary); margin-bottom: 4px; }
.sr-title { font-size: 15px; font-weight: 600; color: var(--text-dark); margin-bottom: 4px; line-height: 1.4; }
.sr-preview { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-emoji {
  width: 40px; height: 40px; border-radius: 10px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}

/* ===== Desktop Responsive ===== */
@media (min-width: 768px) {
  html, body {
    background: #E8E8E3;
  }
  #app {
    max-width: var(--content-max);
    margin: 0 auto;
    background: var(--bg);
    border-left: 1px solid #D8D8D2;
    border-right: 1px solid #D8D8D2;
    box-shadow: 0 0 40px rgba(0,0,0,0.08);
  }
  /* Desktop sidebar tab bar */
  .tab-bar {
    border-top: 1px solid #D8D8D2;
    padding: 10px 0;
  }
  .tab-item {
    font-size: 12px;
    gap: 4px;
    padding: 4px 0;
  }
  .tab-icon {
    width: 26px;
    height: 26px;
  }
  .capsule {
    padding: 8px 20px;
    font-size: 14px;
  }
}
