/* The wallet button, its menu, the wallets panel and the vault dialogs. Builder A owns this file.
   Classes carry the prefix wl- or vault-. Shared classes (.btn, .chip, .card, .tbl, .input, .field, .seg, .stat, .modal,
   .sheet-bottom, .toast, .num, .addr, .soon, ...) live in styles.css: used here, never redefined.
   Colours only through the tokens of styles.css (docs/BLUEPRINT.md section 4.9): no hex colour here. No page may
   scroll sideways at 375 px.
   Names already taken by the board and the token page (css/terminal.css, css/filters.css): not reused.
   .tp .tp-buy .tp-sell .tp-side .tp-sol .tp-t .tp-tx .tp-usd .tp-w (tape rows), .tr-buy .tr-sell (tape flashes),
   .wl .wl-dev .wl-sniper .wl-bundler .wl-kol (wallet labels). */

/* ---------- the top-bar button: an icon and ONE state word (at most 132 px under 560 px) ---------- */
.wl-btn { max-width: 132px; min-width: 0; gap: 6px; padding-left: 9px; padding-right: 11px; overflow: hidden; }
.wl-btn .ico { width: 15px; height: 15px; flex: none; }
.wl-btn-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-btn.wl-st-locked { color: var(--muted); }
.wl-btn.wl-st-session { border-color: var(--brand); color: var(--brand-hi); }
.wl-btn.wl-st-kept { border-color: var(--warn); color: var(--warn); }
.wl-btn.btn-ghost.wl-on { border-color: var(--line-2); color: var(--text); }
.wl-btn.btn-ghost.wl-on.wl-st-session { border-color: var(--brand); color: var(--brand-hi); }
.wl-btn.btn-ghost.wl-on.wl-st-kept { border-color: var(--warn); color: var(--warn); }
.wl-btn.btn-ghost.wl-on.wl-st-locked { color: var(--muted); }
/* locked in this tab, but the kept keys could not be erased from the device: never the calm grey of a clean lock */
.wl-btn.wl-alert, .wl-btn.btn-ghost.wl-on.wl-alert { border-color: var(--warn); color: var(--warn); }

/* ---------- the menu: a child of <body>; a panel under the top bar, a bottom sheet on a phone ---------- */
.wl-menu {
  position: fixed; z-index: 50; top: calc(var(--mock-h) + var(--top-h) + 6px); right: 12px;
  width: min(380px, calc(100vw - 24px)); max-height: calc(100vh - var(--mock-h) - var(--top-h) - var(--tab-h) - 24px);
  overflow-y: auto; overscroll-behavior: contain; padding: 12px;
  border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--bg-2); box-shadow: var(--shadow-pop);
  font-size: 13px;
}
.wl-menu-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.wl-state { display: inline-flex; align-items: center; gap: 7px; min-width: 0; color: var(--text); font: 700 13.5px/1.2 var(--font-ui); }
.wl-state .ico { width: 16px; height: 16px; color: var(--muted); }
.wl-state.wl-st-session .ico { color: var(--brand); }
.wl-state.wl-st-kept, .wl-state.wl-st-kept .ico { color: var(--warn); }
.wl-warn { margin: 6px 0 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--warn); background: var(--warn-soft); color: var(--text); font-size: 12.5px; }
.wl-bal { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-3); }
.wl-bal-k { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font: 700 11px/1.2 var(--font-ui); letter-spacing: 0.04em; text-transform: uppercase; }
.wl-bal-v { flex: none; font-size: 16px; color: var(--text); }
.wl-bal .icon-btn { width: 28px; height: 28px; flex: none; }
.wl-bal .icon-btn .ico { width: 14px; height: 14px; }
.wl-sec { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; margin: 10px 0 4px; }
.wl-sec-t { color: var(--muted); font: 700 11px/1.2 var(--font-ui); letter-spacing: 0.06em; text-transform: uppercase; }
.wl-cta { display: grid; gap: 6px; margin: 2px 0 8px; }
.wl-cta p { margin: 0; }
.wl-cta .wl-warn { margin: 0; }

/* one wallet in the menu: a dot (the active one is orange), its name, its short address, its SOL */
.wl-row { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 40px; margin: 0 0 4px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-3); color: var(--text); text-align: left; }
.wl-row:hover { border-color: var(--line-2); background: var(--hover); }
.wl-row.on { border-color: var(--brand); background: var(--brand-soft); }
.wl-row-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; border: 2px solid var(--line-2); background: transparent; }
.wl-row.on .wl-row-dot, .wl-pick.on .wl-row-dot { border-color: var(--brand); background: var(--brand); }
.wl-row-main { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: center; gap: 3px 7px; min-width: 0; }
.wl-row-l { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 13px/1.3 var(--font-ui); }
.wl-row-a { color: var(--muted); font-size: 11.5px; }
.wl-row-sol { flex: none; color: var(--text); font-size: 12.5px; }

/* the lock's settings */
.wl-lockset { display: grid; gap: 10px; margin: 12px 0 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.wl-set { display: grid; gap: 5px; min-width: 0; }
.wl-set-row { grid-template-columns: 1fr auto; align-items: center; }
.wl-set-row .wl-set-h { grid-column: 1 / -1; }
.wl-set-k { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font: 700 12.5px/1.3 var(--font-ui); }
.wl-set-h { color: var(--muted); font-size: 12px; line-height: 1.4; }
.wl-fact { margin: 0; color: var(--muted); font-size: 12px; }
.wl-switch { position: relative; width: 40px; height: 22px; flex: none; padding: 0; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg-3); }
.wl-switch:disabled { opacity: 0.45; cursor: not-allowed; }
.wl-switch-knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform 0.12s; }
.wl-switch.on { border-color: var(--warn); background: var(--warn-soft); }
.wl-switch.on .wl-switch-knob { background: var(--warn); transform: translateX(18px); }

/* ---------- the wallets panel ---------- */
.wl-panel .card-head { margin-bottom: 12px; }
.wl-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.wl-tblwrap { max-width: 100%; overflow-x: auto; margin: 0 0 10px; border: 1px solid var(--line); border-radius: 8px; }
.wl-tbl td { vertical-align: top; }
.wl-tbl .wl-td-pick { width: 44px; }
.wl-tbl .wl-td-sol { white-space: nowrap; }
.wl-td-w { min-width: 0; }
.wl-td-w > * { margin-right: 7px; vertical-align: middle; }
.wl-td-w .wl-row-l { display: inline-block; max-width: 220px; }
.wl-hint { display: block; margin-top: 3px; color: var(--warn); font-size: 12px; }
.wl-hint.muted { color: var(--muted); }
.wl-pick { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 1px solid transparent; background: transparent; }
.wl-pick:hover { border-color: var(--line-2); background: var(--chip); }
.wl-pick:disabled { opacity: 0.4; cursor: not-allowed; }
.wl-tr.on td { background: var(--brand-soft); }
.wl-tr.wl-archived td { opacity: 0.6; }
.wl-acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.wl-h3 { margin: 18px 0 0; }
.wl-danger { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- the vault dialogs ---------- */
.vault-dlg { display: grid; gap: 10px; min-width: 0; }
.vault-dlg > p, .vault-dlg > h3 { margin: 0; }
.vault-dlg > h3 { margin-top: 6px; color: var(--brand-hi); font: 700 11px/1.3 var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; }
.vault-dlg .field, .vault-dlg .note { margin: 0; }
.vault-err { margin: 10px 0 0; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--down); background: var(--down-soft); color: var(--text); font-size: 13px; }
.vault-warn { margin: 0; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--warn); background: var(--warn-soft); color: var(--text); font-size: 13px; }
.vault-secret { font-family: var(--font-mono); letter-spacing: 0.02em; }
.vault-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; min-width: 0; }
.vault-row .ico { width: 16px; height: 16px; color: var(--up); }
.vault-actions { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: 8px; }
.vault-actions .btn { flex: 1 1 150px; }
.vault-more { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.vault-wallets { display: grid; gap: 6px; }
.vault-wallets p { margin: 0; }
.vault-wallet { justify-content: flex-start; }
.vault-wallet-ico { width: 20px; height: 20px; flex: none; border-radius: 5px; }
.vault-links { display: flex; flex-wrap: wrap; gap: 8px; }
.vault-count { display: flex; align-items: center; gap: 10px; }
.vault-count .field-l { margin-right: auto; }
.vault-count-n { min-width: 26px; text-align: center; font-size: 16px; }
.vault-switch { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.vault-check { width: 16px; height: 16px; flex: none; accent-color: var(--brand); }
.vault-file { width: 100%; padding: 10px; border-radius: 8px; border: 1px dashed var(--line-2); background: var(--bg-3); color: var(--muted); font-size: 13px; }
.vault-file:hover { border-color: var(--brand); }
.vault-list { display: grid; gap: 6px; }
.vault-wl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.vault-deposit { display: grid; gap: 7px; padding: 12px; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand-soft); }
.vault-address { display: block; padding: 9px 10px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); font-size: 12.5px; overflow-wrap: anywhere; user-select: all; }
.vault-qr { justify-self: center; padding: 8px; border-radius: 8px; background: var(--text); }
.vault-qr svg { display: block; max-width: 180px; height: auto; }
.vault-key { display: block; min-height: 64px; padding: 10px; border-radius: 8px; border: 1px solid var(--down); background: var(--bg); color: var(--text); font-size: 12.5px; overflow-wrap: anywhere; user-select: all; }

/* ---------- a phone ---------- */
@media (max-width: 639px) {
  .wl-menu {
    top: auto; right: 0; left: 0; bottom: 0; width: auto; max-height: 86vh;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0; border-bottom: 0; z-index: 55;
  }
  .wl-bar .btn { flex: 1 1 140px; }
  /* the table folds: one wallet is a small card, nothing runs off the side */
  .wl-tblwrap { overflow-x: visible; border: 0; }
  .wl-tbl thead { display: none; }
  .wl-tbl, .wl-tbl tbody { display: block; }
  .wl-tbl tr { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 2px 8px; margin: 0 0 8px; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-3); }
  .wl-tbl tr.on { border-color: var(--brand); }
  .wl-tbl td { padding: 0; border: 0; background: none; }
  .wl-tbl tr:hover td, .wl-tr.on td { background: none; }
  .wl-tbl .wl-td-pick { width: auto; }
  .wl-tbl .wl-td-act { grid-column: 1 / -1; padding-top: 6px; }
  .wl-acts { justify-content: flex-start; }
  .wl-td-w .wl-row-l { max-width: 150px; }
}
@media (max-width: 559px) {
  .wl-btn { padding-left: 8px; padding-right: 9px; font-size: 12px; }
}
