:root {
  --app-bg: #0b0b0b;
  --app-surface: #141414;
  --tabbar-bg: rgba(8, 10, 7, 0.86);
  --tabbar-inactive: #7c8474;
  --tabbar-active: #b6f53a;
  --tabbar-border: rgba(182, 245, 58, 0.16);
  --app-text: #f2f2f2;
  --app-text-muted: #8a8a89;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --tabbar-height: 68px;
  --app-header-height: 56px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: "MiSans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* 启动 / i18n 未完成：隐藏真实内容，显示骨架屏 */
html.awa-booting .app-shell {
  visibility: hidden;
}

html.awa-boot-ready .app-shell {
  visibility: visible;
}

/* ---------- 全局骨架屏 ---------- */
.app-skeleton {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  justify-content: center;
  background: var(--app-bg);
  pointer-events: none;
}

.app-skeleton[hidden] {
  display: none !important;
}

.app-skeleton-inner {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--tabbar-height) + var(--safe-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-sk-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.app-sk-circle {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  flex-shrink: 0;
  background: linear-gradient(90deg, #1a1a1a 0%, #252525 50%, #1a1a1a 100%);
  background-size: 200% 100%;
  animation: app-sk-shimmer 1.2s ease-in-out infinite;
}

.app-sk-line,
.app-sk-chip,
.app-sk-card,
.app-sk-tab,
.app-sk-item {
  background: linear-gradient(90deg, #161616 0%, #222 50%, #161616 100%);
  background-size: 200% 100%;
  animation: app-sk-shimmer 1.2s ease-in-out infinite;
  border-radius: 8px;
}

.app-sk-line {
  display: block;
  height: 12px;
}

.app-sk-line.sk-mt {
  margin-top: 10px;
}

.app-sk-line.sk-w20 { width: 20%; }
.app-sk-line.sk-w35 { width: 35%; }
.app-sk-line.sk-w40 { width: 40%; }
.app-sk-line.sk-w45 { width: 45%; }
.app-sk-line.sk-w50 { width: 50%; }
.app-sk-line.sk-w55 { width: 55%; }
.app-sk-line.sk-w70 { width: 70%; }
.app-sk-line.sk-w80 { width: 80%; }

.app-sk-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.app-sk-card {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  min-height: 88px;
}

.app-sk-tabbar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.app-sk-tab {
  width: 44px;
  height: 28px;
  border-radius: 8px;
}

.app-sk-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-sk-item {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(20, 20, 20, 0.6);
}

.app-sk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.app-sk-chip {
  width: 52px;
  height: 22px;
  border-radius: 999px;
  flex-shrink: 0;
}

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

@media (prefers-reduced-motion: reduce) {
  .app-sk-line,
  .app-sk-chip,
  .app-sk-card,
  .app-sk-tab,
  .app-sk-item,
  .app-sk-circle {
    animation: none;
  }
}

body {
  overscroll-behavior-y: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  background: var(--app-bg);
  position: relative;
}

.app-main {
  flex: 1;
  width: 100%;
  padding: 20px 16px calc(var(--tabbar-height) + var(--safe-bottom) + 16px);
}

.app-list-more {
  padding: 14px 12px 4px;
  text-align: center;
  font-size: 12px;
  line-height: 1;
  color: #7c7c7b;
}

.app-list-more[hidden] {
  display: none !important;
}

.app-tab-panels {
  position: relative;
  width: 100%;
}

.app-tab-panel {
  width: 100%;
}

/* Tab 常駐：visibility 切換，避免 display:none 重排與進場動畫重播 */
html.awa-tab-app .app-tab-panel:not(.is-active) {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  z-index: 0;
}

html.awa-tab-app .app-tab-panel.is-active {
  position: relative;
  height: auto;
  overflow: visible;
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
}

/* Tab 內禁用進場淡入，切換時不再「閃一下」 */
html.awa-tab-app .app-tab-panel .home-reveal {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

html.awa-tab-app .app-tab-panel:not(.is-active) *,
html.awa-tab-app .app-tab-panel:not(.is-active) *::before,
html.awa-tab-app .app-tab-panel:not(.is-active) *::after {
  animation-play-state: paused !important;
  transition: none !important;
}

/* 多 Tab 面板常駐時，僅作用於當前可見面板，避免 :has 串頁 */
.app-main:has(.app-tab-panel.is-active .home-page) {
  padding: 0 0 calc(var(--tabbar-height) + var(--safe-bottom));
  background: #020302;
}

.app-main:has(.app-tab-panel.is-active .arb-page) {
  padding: 0 0 calc(var(--tabbar-height) + var(--safe-bottom));
  background: #020302;
}

.app-main:has(.app-tab-panel.is-active .contract-page) {
  padding: 0 0 calc(var(--tabbar-height) + var(--safe-bottom));
  background: #020302;
}

.app-main:has(.app-tab-panel.is-active .stake-page) {
  padding: 0 0 calc(var(--tabbar-height) + var(--safe-bottom));
  background: #020302;
}

.app-main:has(.app-tab-panel.is-active .mine-page) {
  padding: 0 0 calc(var(--tabbar-height) + var(--safe-bottom));
  background: #020302;
}

.app-toast:not(.show) {
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Tab Shell 同时加载多页 CSS，contract.css 的 top:42% 会与 bottom 叠加把 Toast 撑满屏 */
html.awa-tab-app .app-toast {
  position: fixed;
  left: 50%;
  top: auto;
  bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 24px);
  width: max-content;
  max-width: min(86vw, 360px);
  height: auto;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(10, 14, 8, 0.94);
  border: 1px solid rgba(182, 245, 58, 0.22);
  color: #f2f2f2;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  box-sizing: border-box;
  box-shadow: 0 0 24px rgba(182, 245, 58, 0.12);
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 240;
}

html.awa-tab-app .app-toast.show {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.mine-header,
.stake-header,
.contract-header,
.ex-header,
.home-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
  height: calc(var(--app-header-height) + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  box-sizing: border-box;
  z-index: 90;
  background: linear-gradient(180deg, rgba(2, 3, 2, 0.94), rgba(2, 3, 2, 0.78) 75%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: none;
}

.mine-page,
.stake-page,
.contract-page,
.exchange-page,
.home-page {
  padding-top: calc(var(--app-header-height) + var(--safe-top) + 12px) !important;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--tabbar-height) + var(--safe-bottom));
  padding: 8px 10px var(--safe-bottom);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  gap: 2px;
  background:
    linear-gradient(180deg, rgba(182, 245, 58, 0.05), transparent 28%),
    var(--tabbar-bg);
  border-top: 1px solid var(--tabbar-border);
  box-shadow:
    0 -12px 36px rgba(0, 0, 0, 0.45),
    0 -1px 0 rgba(182, 245, 58, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  z-index: 100;
}

.tabbar::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(182, 245, 58, 0.55), transparent);
  opacity: 0.9;
  pointer-events: none;
}

.tabbar-item {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  min-width: 0;
  padding: 6px 4px 4px;
  border-radius: 14px;
  color: var(--tabbar-inactive);
  transition: color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.tabbar-item:active {
  transform: scale(0.94);
}

.tabbar-icon {
  width: 28px;
  height: 28px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 10px;
  transition: transform 0.2s ease, filter 0.2s ease, background 0.2s ease;
}

.tabbar-icon img {
  position: absolute;
  inset: 0;
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
  transition: opacity 0.18s ease;
}

.tabbar-icon .icon-active {
  opacity: 0;
}

.tabbar-icon .icon-normal {
  opacity: 1;
}

.tabbar-label {
  font-size: 11px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: inherit;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.tabbar-item.is-active {
  color: var(--tabbar-active);
}

.tabbar-item.is-active .tabbar-icon {
  background: rgba(182, 245, 58, 0.12);
  box-shadow:
    0 0 0 1px rgba(182, 245, 58, 0.22),
    0 0 16px rgba(182, 245, 58, 0.22);
  filter: drop-shadow(0 0 6px rgba(182, 245, 58, 0.35));
  transform: translateY(-1px);
}

.tabbar-item.is-active .tabbar-label {
  font-weight: 650;
  text-shadow: 0 0 12px rgba(182, 245, 58, 0.35);
}

.tabbar-item.is-active .icon-normal {
  opacity: 0;
}

.tabbar-item.is-active .icon-active {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .tabbar-item,
  .tabbar-icon,
  .tabbar-icon img,
  .tabbar-label {
    transition: none !important;
  }
}

/* 语言下拉（顶栏共用） */
.app-lang-wrap {
  position: relative;
  flex-shrink: 0;
}

/* 顶栏按钮仅显示图标，语言名称在下拉菜单中展示 */
.js-app-lang-btn .js-app-lang-label,
.js-app-lang-btn [class$="-lang-caret"] {
  display: none !important;
}

.js-app-lang-btn {
  gap: 4px;
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
  min-width: auto;
}

.js-app-lang-prefix {
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  color: inherit;
}

.js-app-lang-btn img,
.js-app-lang-btn .js-app-lang-btn-icon {
  width: 18px;
  height: 18px;
}

.app-lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 120px;
  padding: 6px;
  border-radius: 10px;
  background: #121212;
  border: 1px solid #242424;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 110;
}

.app-lang-menu[hidden] {
  display: none !important;
}

.app-lang-item {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #f2f2f2;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  text-align: left;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-lang-item-icon,
.js-app-lang-btn-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
  background: #1a1a1a;
}

.app-lang-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-lang-empty {
  padding: 10px;
  font-size: 12px;
  color: #7c7c7b;
  text-align: center;
}

.app-lang-item:active,
.app-lang-item.is-active {
  background: rgba(163, 213, 47, 0.12);
  color: #a3d52f;
}

.app-lang-wrap.open .mine-lang-caret,
.app-lang-wrap.open .home-lang-caret,
.app-lang-wrap.open .ex-lang-caret,
.app-lang-wrap.open .stake-lang-caret,
.app-lang-wrap.open .contract-lang-caret {
  transform: rotate(180deg);
}

.mine-lang-caret,
.home-lang-caret,
.ex-lang-caret,
.stake-lang-caret,
.contract-lang-caret {
  transition: transform 0.18s ease;
}

html.awa-scroll-lock {
  overflow: hidden;
  overscroll-behavior: none;
}

html.awa-scroll-lock body {
  overflow: hidden;
  overscroll-behavior: none;
}
