/* MetaMask 内置浏览器壳 */
:root {
  --mm-chrome-bg: #ffffff;
  --mm-chrome-border: #e5e7eb;
  --mm-chrome-text: #111827;
  --mm-chrome-muted: #6b7280;
  --mm-url-bg: #ffffff;
  --mm-top-height: 48px;
  --mm-site-header-height: 52px;
  --mm-bottom-height: 50px;
  --mm-status-height: 44px;
}

.device-shell {
  display: inline-block;
  padding: 12px;
  background: #000;
  border-radius: 60px;
  box-shadow: 0 0 0 2px #1f2937, 0 20px 60px rgba(0, 0, 0, 0.45);
}

.mm-browser {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 393px;
  height: 852px;
  border-radius: 48px;
  overflow: hidden;
  background: var(--screen-bg);
  isolation: isolate;
}

/* 系统状态栏 */
.mm-status-bar {
  flex-shrink: 0;
  height: var(--mm-status-height);
  padding: 14px 28px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--mm-chrome-bg);
  color: var(--mm-chrome-text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.mm-status-bar__right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.mm-status-bar__right i {
  font-size: 13px;
}

/* 顶部浏览器栏 */
.mm-top-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--mm-top-height);
  padding: 0 10px 8px;
  background: var(--mm-chrome-bg);
  border-bottom: 1px solid var(--mm-chrome-border);
}

.mm-nav-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--mm-chrome-text);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.mm-nav-btn:active {
  background: #f3f4f6;
}

.mm-url-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  background: var(--mm-url-bg);
  border: 1px solid var(--mm-chrome-border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.mm-url-bar__lock {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--mm-chrome-muted);
}

.mm-url-bar__text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--mm-chrome-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mm-tab-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--mm-chrome-border);
  border-radius: 8px;
  background: #fff;
  color: var(--mm-chrome-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mm-menu-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
}

.mm-menu-btn img {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 8px;
}

/* 站点顶栏（WEA + 网络/钱包） */
.site-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--mm-site-header-height);
  padding: 0 16px;
  background: var(--screen-bg);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 50;
}

.site-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
  flex-shrink: 0;
  white-space: nowrap;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.site-header__wallet {
  position: relative;
  flex-shrink: 0;
}

.lang-switch {
  position: relative;
  flex-shrink: 0;
}

.lang-switch__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.lang-switch__trigger:hover,
.lang-switch__trigger.is-open {
  color: #fff;
  border-color: rgba(59, 130, 246, 0.45);
  background: var(--surface-elevated);
}

.lang-switch__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 136px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-elevated);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 120;
}

.lang-switch__option {
  display: flex;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-switch__option.is-active {
  color: #fff;
  background: rgba(59, 130, 246, 0.18);
}

.lang-switch__option:hover:not(.is-active) {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

/* 连接钱包触发按钮（未连接） */
.wallet-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.wallet-trigger:hover,
.wallet-trigger.is-open {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}

.wallet-trigger__icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  font-size: 11px;
  color: #fff;
}

.wallet-trigger__chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.wallet-trigger.is-open .wallet-trigger__chevron {
  transform: rotate(180deg);
}

.network-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 8px;
  background: #ffffff;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  border: none;
  font-family: inherit;
  cursor: default;
}

.network-pill--clickable {
  cursor: pointer;
}

.network-pill--clickable:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.network-pill--clickable.is-open {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.network-pill__chevron {
  font-size: 10px;
  color: #6b7280;
  margin-left: 2px;
  transition: transform 0.2s;
}

.network-pill--clickable.is-open .network-pill__chevron {
  transform: rotate(180deg);
}

/* 已连接账户菜单 */
.wallet-account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  min-width: 160px;
  padding: 6px;
  background: #111111;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.wallet-account-menu.hidden {
  display: none;
}

.wallet-account-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #f87171;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}

.wallet-account-menu__item:hover {
  background: rgba(248, 113, 113, 0.12);
}

.wallet-account-menu__item i {
  font-size: 14px;
}

.network-pill__icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.network-pill__icon--sol {
  background: var(--icon-solana-chain) center / cover no-repeat;
  color: transparent;
}

.network-pill__icon--polygon {
  background: var(--icon-polygon-chain) center / cover no-repeat;
  color: transparent;
}

.network-pill__text {
  font-size: 13px;
  font-weight: 500;
  color: #111827;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 钱包连接下拉框 */
.wallet-dropdown-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: transparent;
}

.wallet-dropdown-backdrop.hidden,
.wallet-dropdown.hidden {
  display: none;
}

.wallet-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  width: 280px;
  padding: 12px;
  background: #111111;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.wallet-dropdown__label {
  margin: 0 0 8px;
  padding: 0 4px;
  font-size: 12px;
  color: #9ca3af;
}

.wallet-dropdown__divider {
  height: 1px;
  margin: 12px 0;
  background: rgba(255, 255, 255, 0.1);
}

.wallet-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  margin-bottom: 8px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.wallet-option:last-child {
  margin-bottom: 0;
}

.wallet-option:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
}

.wallet-option--disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  color: #9ca3af;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.wallet-option--disabled:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.08);
}

.wallet-option--disabled .wallet-option__icon {
  opacity: 0.65;
}

.wallet-network-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 8px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

.wallet-network-row:last-of-type {
  margin-bottom: 0;
}

.wallet-network-row__info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.wallet-network-row__name {
  font-size: 15px;
  font-weight: 500;
  color: #fff;
}

.wallet-network-row__link {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 500;
  color: #a855f7;
  text-decoration: none;
  padding: 6px 4px;
}

.wallet-network-row__link:hover {
  color: #c084fc;
  text-decoration: underline;
}

.wallet-option__icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
}

.wallet-option__icon--eth {
  background: #627eea;
}

.wallet-option__icon--netx {
  background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  font-size: 12px;
  font-weight: 700;
}

.wallet-option__icon--bnb {
  background: #f0b90b;
  color: #1a1a1a;
  font-size: 13px;
}

.wallet-option__icon--sol {
  background: var(--icon-solana-chain) center / cover no-repeat;
  color: transparent;
  font-size: 0;
}

.wallet-option__icon--polygon {
  background: var(--icon-polygon-chain) center / cover no-repeat;
  color: transparent;
  font-size: 0;
}

.wallet-option__icon--ton {
  background: #0098ea;
  font-size: 11px;
  font-weight: 700;
}

.wallet-option__icon--x {
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.wallet-option__icon--google {
  background: #fff;
  color: #4285f4;
  font-weight: 700;
  font-size: 16px;
}

.wallet-option__icon--world {
  background: #fff;
  color: #111;
  font-size: 16px;
}

.wallet-option__icon--telegram {
  background: #26a5e4;
}

/* 正文区：外层固定高度，内层滚动，弹层覆盖可视区 */
.mm-content {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--screen-bg);
}

.mm-content__scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  touch-action: pan-y;
}

.mm-content__scroll::-webkit-scrollbar {
  display: none;
}

.mm-content.is-sheet-open .mm-content__scroll {
  overflow: hidden;
  touch-action: none;
}

/* 弹层固定在正文可视区底部，不随内容滚动偏移 */
.mm-sheet-layer {
  position: absolute;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}

.mm-content .app-shell {
  position: relative;
  z-index: 1;
  padding-bottom: 16px;
}

/* 底部浏览器工具栏 */
.mm-bottom-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--mm-bottom-height);
  padding: 0 8px env(safe-area-inset-bottom, 0);
  background: var(--mm-chrome-bg);
  border-top: 1px solid var(--mm-chrome-border);
}

.mm-bottom-bar__btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--mm-chrome-text);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.mm-bottom-bar__btn:disabled {
  color: #d1d5db;
  cursor: default;
}

.mm-bottom-bar__btn:not(:disabled):active {
  background: #f3f4f6;
}

.mm-bottom-bar__btn .fa-star {
  color: var(--mm-chrome-muted);
}

.mm-bottom-bar__btn.is-bookmarked .fa-star {
  color: #f59e0b;
}

/* Home Indicator */
.mm-home-indicator {
  flex-shrink: 0;
  height: 20px;
  background: var(--mm-chrome-bg);
  position: relative;
}

.mm-home-indicator::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  background: #111827;
  border-radius: 999px;
  opacity: 0.85;
}

@media (max-width: 768px) {
  body {
    display: block;
    background: var(--screen-bg);
  }

  .device-shell {
    display: block;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
  }

  .mm-browser {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }

  .mm-status-bar {
    padding-top: max(14px, env(safe-area-inset-top, 14px));
  }

  .mm-home-indicator {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}
