/* Keep the connected-wallet menu readable and inside the viewport. */
html body.app-mode .site-header:has(#walletMenu:not([hidden])) { z-index: 1200; }
html body.app-mode #walletControl.is-connected > #wallet {
  box-sizing: border-box;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  width: auto;
  min-width: 0;
  max-width: none;
  overflow: visible;
  padding: 8px 12px;
  border-radius: 6px !important;
  color: var(--sc-ink, #0f1417) !important;
  -webkit-text-fill-color: var(--sc-ink, #0f1417) !important;
}
html body.app-mode #walletControl.is-connected > #wallet::before {
  content: "";
  display: block;
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--sc-success, #1e7a4c);
}
html body.app-mode #walletControl.is-connected > #wallet::after {
  content: none !important;
  display: none !important;
}
html body.app-mode #walletControl.is-connected > #wallet .wallet-address-text {
  display: block;
  flex: 0 0 auto;
  min-width: 0;
  max-width: none;
  overflow: visible;
  color: var(--sc-ink, #0f1417) !important;
  -webkit-text-fill-color: var(--sc-ink, #0f1417) !important;
  font: inherit;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  opacity: 1;
  white-space: nowrap;
}
html body.app-mode #walletMenu[hidden] { display: none !important; }
html body.app-mode #walletMenu:not([hidden]) {
  position: fixed !important;
  top: 60px;
  left: 12px;
  right: auto !important;
  z-index: 1100 !important;
  box-sizing: border-box;
  width: min(300px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--sc-border, #d8d6ce);
  border-radius: 10px;
  background: var(--sc-surface, #fff);
  color: var(--sc-ink, #0f1417);
  box-shadow: 0 16px 40px rgb(15 20 23 / .16), 0 3px 10px rgb(15 20 23 / .06);
}
html[data-theme="dark"] body.app-mode #walletMenu:not([hidden]) {
  background: var(--sc-surface, #161b1f);
  box-shadow: 0 16px 40px rgb(0 0 0 / .42), 0 3px 10px rgb(0 0 0 / .18);
}
html body.app-mode #walletMenu .wallet-menu-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--sc-ink, #0f1417);
  font: 600 13px/1.3 var(--sc-font, Inter, sans-serif);
}
html body.app-mode #walletMenu .wallet-menu-label::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--sc-success, #1e7a4c);
}
html body.app-mode #walletMenu .wallet-menu-identity {
  padding: 12px;
  border: 1px solid var(--sc-border, #d8d6ce);
  border-radius: 7px;
  background: var(--sc-elevated, #ecebe6);
}
html body.app-mode #walletMenu .wallet-menu-address-label {
  display: block;
  margin-bottom: 5px;
  color: var(--sc-ink-2, #4a5459);
  font: 500 11px/1.3 var(--sc-font, Inter, sans-serif);
}
html body.app-mode #walletMenu #walletMenuAddress {
  display: block;
  overflow: hidden;
  color: var(--sc-ink, #0f1417);
  font: 600 14px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: -.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
}
html body.app-mode #walletMenu .wallet-menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
html body.app-mode #walletMenu .wallet-menu-actions button:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--sc-border, #d8d6ce);
  border-radius: 6px;
  background: var(--sc-surface, #fff);
  color: var(--sc-ink, #0f1417) !important;
  font: 600 12px/1.2 var(--sc-font, Inter, sans-serif);
  white-space: nowrap;
  cursor: pointer;
}
html body.app-mode #walletMenu .wallet-menu-actions button:hover { border-color: var(--sc-accent, #2456e0); }
html body.app-mode #walletMenu .wallet-menu-actions button:focus-visible { outline: 2px solid var(--sc-accent, #2456e0); outline-offset: 2px; }
html body.app-mode #walletMenu #disconnectWallet:hover { border-color: var(--sc-danger, #a12f2f); color: var(--sc-danger, #a12f2f) !important; }
html body.app-mode #walletMenu #copyWalletAddress[hidden] + #disconnectWallet { grid-column: 1 / -1; }
@media (max-width: 380px) {
  html body.app-mode #walletMenu:not([hidden]) { padding: 14px; }
}
@media (max-width: 620px) {
  html body.app-mode .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 5px 8px;
    align-items: center;
  }
  html body.app-mode .header-left { display: contents; }
  html body.app-mode .header-left .brand-link { grid-column: 1; grid-row: 1; justify-self: start; }
  html body.app-mode .header-left .site-nav { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  html body.app-mode .header-actions { grid-column: 2; grid-row: 1; gap: 5px; }
  html body.app-mode #walletControl.is-connected > #wallet {
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 6px 8px;
    font-size: 10px;
  }
  html body.app-mode #walletControl.is-connected > #wallet::before { margin-right: 6px; }
}
