.wallet-owner-actions, #promptmodal, .wallet-dialog {
  --wiki-yellow: #ffc700;
  --wiki-text: #f5f2ec;
  --wiki-display: "Oldschool Grotesk Condensed", "Arial Narrow", sans-serif;
}
.wallet-dialog {
  /* Columns of ~184px cards, plus padding, the wallet column and the gap between. */
  width: min(calc(var(--wallet-columns, 3) * 198px + 336px), calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  border: 1px solid #303030; border-radius: 24px; background: #191919; color: #e8e8ea;
  box-shadow: 0 24px 100px #0009, inset 0 1px 0 #ffffff04;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}
.wallet-dialog::backdrop { background: #000b; backdrop-filter: blur(9px); }
.wallet-dialog.wallet-picker { width: min(480px, calc(100vw - 32px)); }
.wallet-dialog [hidden] { display: none !important; }
.wallet-dialog > header { gap: 10px; padding: 26px 28px 22px; border: 0; background: #191919; }
.wallet-dialog h2 { flex: 1; margin: 0; font: 650 22px/1.3 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -.5px; text-transform: none; }
.wallet-dialog .sheet-body { padding: 0 28px 28px; font-size: 14px; line-height: 1.5; }
.wallet-dialog .wallet-button:where(:not(.wiki-btn)) { box-sizing: border-box; font: inherit; color: inherit; cursor: pointer; }
.wallet-dialog .wallet-button:disabled { opacity: .5; cursor: wait; }
.wallet-dialog button:focus-visible, .wallet-dialog a:focus-visible { outline: 2px solid var(--wiki-yellow); outline-offset: 3px; }
.wallet-dialog svg { display: block; flex: none; width: 18px; height: 18px; }
.wallet-dialog .wallet-icon-button {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none;
  padding: 4px; border: 0; border-radius: 7px; color: #73777b; background: transparent; text-decoration: none;
}
.wallet-dialog .wallet-icon-button:hover { color: #ececed; background: #ffffff09; }
/* Header controls mirror the title: matching glyph sizes and strokes, equal gaps between them,
   and the X glyph flush with the content's right edge as the title is with its left. */
.wallet-dialog .wallet-refresh, .wallet-dialog .wallet-close { width: 32px; height: 32px; padding: 0; }
.wallet-dialog :is(.wallet-refresh, .wallet-close) path { vector-effect: non-scaling-stroke; stroke-width: 1.6px; }
.wallet-dialog .wallet-refresh svg { width: 20px; height: 20px; }
.wallet-dialog .wallet-close { margin: 0 -9.5px; }
.wallet-dialog .wallet-close svg { width: 26px; height: 26px; }
.wallet-dialog .wallet-back { margin-left: -8px; }
.wallet-sync { flex: 0 1 auto; min-width: 0; margin: 0; overflow: hidden; color: #7c8085; font-size: 12px; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; }
.wallet-sync.is-working { color: #e8e8ea; }
.wallet-sync.is-done { color: #8ed3a0; }
.wallet-sync.is-error { color: #ff9c89; }
.wallet-dialog .wallet-refresh.is-spinning { color: var(--wiki-yellow); opacity: 1; cursor: progress; }
.wallet-refresh.is-spinning svg { animation: wallet-spin .9s linear infinite; }
.wallet-provider-list { display: grid; gap: 10px; }
.wallet-connection-guide { margin: 0 0 20px; padding: 15px 17px; border: 1px solid #36312d; border-radius: 14px; background: #221f1c; }
.wallet-guide-title { margin: 0 0 8px; color: #f5ede4; font-size: 14px; font-weight: 650; }
.wallet-connection-guide ol { margin: 0; padding-left: 20px; color: #b4ada5; font-size: 12px; line-height: 1.55; }
.wallet-connection-guide li + li { margin-top: 4px; }
.wallet-guide-explanation { margin: 10px 0 0; color: #b4ada5; font-size: 12px; line-height: 1.55; }
.wallet-dialog .wallet-provider {
  display: flex; align-items: center; gap: 18px; width: 100%; min-height: 88px; padding: 18px 20px;
  border: 1px solid #272727; border-radius: 18px; text-align: left; background: #202020;
  transition: background .15s, border-color .15s;
}
.wallet-dialog .wallet-provider:hover:not(:disabled) { background: #272727; border-color: #3b3b3b; }
.wallet-provider-icon { display: block; width: 48px; height: 48px; flex: none; object-fit: contain; border-radius: 13px; }
.wallet-provider-name { flex: 1; font-size: 18px; font-weight: 650; letter-spacing: -.3px; }
.wallet-provider-ready { width: 10px; height: 10px; flex: none; margin-right: 3px; border-radius: 50%; background: #21c767; box-shadow: 0 0 12px #21c76733; }
.wallet-provider-unavailable { padding: 4px 9px; border-radius: 8px; background: #111; color: #6e7378; font-size: 12px; white-space: nowrap; }
.wallet-help { color: #85898e; font-size: 12px; line-height: 1.65; }
.wallet-picker-help { margin: 22px 4px 0; text-align: center; }
.wallet-dialog .wallet-sign-in { display: block; width: 100%; margin-top: 16px; padding: 12px; border: 1px solid #3a3a3a; border-radius: 12px; background: #292929; font-weight: 600; }
.wallet-dialog .wallet-sign-in:hover { background: #333; }
.wallet-dashboard { display: grid; grid-template-columns: minmax(0, 1fr) 256px; gap: 24px; align-items: start; }
.wallet-sidebar, .wallet-holdings { min-width: 0; }
.wallet-dialog .wallet-text-button { border: 0; padding: 4px 0; background: none; color: #94989c; font-size: 12px; }
.wallet-dialog .wallet-text-button:hover { color: #f2f2f2; }
.wallet-dialog .wallet-retry { display: block; margin: 16px auto 0; color: #ff9a64; }
/* Tucked under Add Wallet; the negative bottom margin lets the dialog padding alone set the gap below the text. */
.wallet-sidebar .wallet-text-button { display: block; margin: 4px auto -8px; padding: 6px 12px; }
.wallet-accounts { display: grid; gap: 8px; }
.wallet-account { box-sizing: border-box; min-width: 0; padding: 10px 10px 8px 12px; border: 1px solid #2b2b2b; border-radius: 14px; background: #202020; }
.wallet-account-top { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 28px; }
.wallet-account-top > .wallet-provider-icon { width: 28px; height: 28px; border-radius: 8px; }
.wallet-dialog .wallet-account h3 { flex: 1; min-width: 0; margin: 0; overflow: hidden; font-family: inherit; font-size: 14px; line-height: 1.3; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.wallet-account-count { flex: none; color: #8f9397; font-size: 12px; line-height: 1.3; }
.wallet-account-count.is-checking { color: #ff9a64; }
.wallet-dialog .wallet-remove-account { flex: none; padding: 4px 8px; border: 1px solid #734536; border-radius: 999px; background: #31231f; color: #ffad94; font-size: 11px; }
.wallet-dialog .wallet-remove-account:hover { background: #493027; }
.wallet-addresses { display: grid; gap: 1px; margin: 6px 0 0; padding: 0 0 0 32px; list-style: none; }
.wallet-dialog .wallet-addresses li { margin: 0; }
.wallet-dialog .wallet-address {
  display: flex; align-items: center; gap: 7px; width: 100%; padding: 3px 6px; border: 0; border-radius: 6px;
  background: none; color: #92969a; font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-align: left;
}
.wallet-dialog .wallet-address:hover { background: #ffffff08; color: #e8e8ea; }
.wallet-dialog .wallet-address svg { width: 13px; height: 13px; opacity: .65; }
.wallet-dialog .wallet-add {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 42px; margin-top: 8px;
  padding: 10px; border: 1px dashed #383838; border-radius: 14px; background: transparent; color: #8f9398; font-size: 13px; font-weight: 600;
}
.wallet-dialog .wallet-add:hover { border-color: #656565; color: #e8e8ea; background: #ffffff03; }
.wallet-dialog .wallet-add svg { width: 16px; height: 16px; }
.wallet-ninjas { display: grid; grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 14px; }
.wallet-ninja { display: flex; flex-direction: column; min-width: 0; padding: 10px; border: 1px solid #2c2c2c; border-radius: 16px; background: #202020; }
.wallet-ninja img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 10px; background: #151515; }
.wallet-ninja-identity { display: flex; align-items: center; gap: 6px; min-width: 0; margin: 10px 2px 0; }
.wallet-dialog .wallet-ninja h3 { flex: 1; min-width: 0; margin: 0; overflow: hidden; font-family: inherit; font-size: 14px; font-weight: 650; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
.wallet-ninja-level { flex: none; margin-left: auto; color: #f9cd64; font-size: 11px; font-weight: 700; white-space: nowrap; }
.wallet-ninja p { margin: 2px 2px 0; color: #979b9f; font-size: 12px; }
.wallet-card-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.wallet-dialog .wallet-card-actions .wiki-btn { min-width: 0; padding: 7px 6px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.wallet-dialog .wallet-owner-control { width: 100%; margin-top: 6px; padding: 4px; border: 0; border-radius: 7px; background: transparent; color: #8f9397; font-size: 11px; font-weight: 600; }
.wallet-dialog .wallet-owner-control:hover:not(:disabled) { color: #e8e8ea; }
.wallet-owner-control .is-on { color: #8ed3a0; }
.wallet-owner-control .is-off { color: #ff9c89; }
.wallet-ninja .wallet-help { font-size: 11px; line-height: 1.4; }
.wallet-empty { margin: 0; padding: 28px 20px; border: 1px solid #292929; border-radius: 16px; color: #93989c; font-size: 14px; line-height: 1.7; }
.wallet-notice { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: #2b251e; color: #d5b69e; font-size: 12px; }
.wallet-progress { display: flex; align-items: center; gap: 10px; margin: 22px 0 0; color: #ff9a64; font-size: 13px; }
.wallet-connect-progress { margin: 0 0 18px; }
.wallet-progress::before { content: ''; width: 12px; height: 12px; flex: none; border: 2px solid #784226; border-top-color: #ff8b4c; border-radius: 50%; animation: wallet-spin .8s linear infinite; }
.wallet-status { margin: 0 28px 18px; color: #a3a7ab; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.wallet-status:empty { display: none; }
.wallet-status.wiki-error { color: #ff9c89; }
.wallet-owner-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.wallet-context { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; font: 13px/1.5 sans-serif; }
@keyframes wallet-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .wallet-progress::before, .wallet-refresh.is-spinning svg { animation: none; } .wallet-provider { transition: none; } }
@media (max-width: 760px) {
  .wallet-dialog { width: min(540px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); }
  .wallet-dashboard { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .wallet-ninjas { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .wallet-dialog > header { flex-wrap: wrap; row-gap: 4px; }
  .wallet-sync { order: 1; flex-basis: 100%; text-align: right; }
  .wallet-sync.is-idle { display: none; }
  .wallet-dialog > header { padding: 24px 22px 20px; }
  .wallet-dialog .sheet-body { padding: 0 22px 24px; }
  .wallet-status { margin: 0 22px 22px; }
}
@media (max-width: 400px) {
  .wallet-dialog h2 { font-size: 20px; }
  .wallet-dialog > header { padding-inline: 18px; }
  .wallet-dialog .sheet-body { padding-inline: 18px; }
  .wallet-dialog .wallet-provider { padding: 16px 14px; gap: 12px; }
  .wallet-provider-name { font-size: 17px; }
  .wallet-provider-icon { width: 40px; height: 40px; border-radius: 11px; }
  .wallet-provider-unavailable { font-size: 11px; padding: 4px 6px; }
  .wallet-ninjas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wallet-card-actions { grid-template-columns: minmax(0, 1fr); }
  .wallet-dialog .wallet-ninja h3 { font-size: 13px; }
}
@container stage (min-width: 1051px) and (max-width: 1550px) {
  #toplinks #walletbtn { width: 46px; padding: 0; }
  #walletbtn span { display: none; }
}
@container stage (max-width: 740px) {
  #toplinks #walletbtn { flex: 0 0 46px; width: 46px; padding: 0; }
  #walletbtn span { display: none; }
  #toplinks #walletbtn svg { display: block; }
}
