/* Vault window (src/ui/vault.js): bag | vault in a large pop-up, plus the amount dialog for stacks. Semantic tokens from
   style.css only; no gold text.
   Performance (Firefox): the window stays open over the battle canvas while the battle runs, and Firefox re-rasterises
   whatever overlaps the canvas every frame (see the note in style.css). So: a plain see-through backdrop without blur
   (.modal-wrap.plain), an opaque window, square corners everywhere inside (rounded backgrounds are clip masks too), no
   filters (the corner ornaments of .modal are off), shadows without blur, no rounded clipping. */
.modal-wrap.plain { backdrop-filter: none; -webkit-backdrop-filter: none; }
:is(.vault-win, .vault-qty), :is(.vault-win, .vault-qty) :is(.btn, .chip, .seg, .seg-btn, .icon-btn, .pill, input, select, .npc-portrait, .opt-pips i) { border-radius: 0; }
:is(.vault-win, .vault-qty) :is(.btn, .btn.primary, .chip, .seg-btn, .seg-btn.on, .icon-btn) { box-shadow: none; text-shadow: none; }
:is(.vault-win, .vault-qty) .opt-pips i { box-shadow: none; }
.modal.vault-win::after, .modal.vault-qty::after { display: none; }
.modal.vault-win, .modal.vault-qty { background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--frame-hi), 0 4px 0 var(--shade); }

/* ---------------------------------------------------------------- the window */
.modal.vault-win {
  width: min(1180px, 100%); height: min(920px, calc(100dvh - 32px)); max-height: none; overflow: hidden;
  padding: 12px 14px 10px; gap: 10px;
}
.vw-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.vw-head .npc-portrait { width: 46px; height: 46px; box-shadow: none; }
.vw-title { flex: 1; min-width: 0; }
.vw-title .h3 { margin: 0; }
.vw-quote { color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vw-quote b { color: var(--accent-text); font-weight: 800; }
.vw-quote span { font-style: italic; }
.vw-x { width: 38px; height: 38px; font-size: 24px; line-height: 1; }
.vw-switch { display: none; }
.vw-n { font-size: var(--fs-micro); font-weight: 800; opacity: 0.8; font-variant-numeric: tabular-nums; }

.vw-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.vw-pane {
  display: flex; flex-direction: column; gap: 7px; min-width: 0; min-height: 0; padding: 10px 10px 8px;
  background: var(--surface-2); border: 1px solid var(--border-soft); box-shadow: inset 0 1px 0 var(--frame-hi);
}
.vw-ph { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-height: 32px; }
.vw-ph .h4 { margin: 0; font-size: var(--fs-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vw-who { font-family: var(--font); font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0; color: var(--text-muted); }
.vw-count { flex: none; font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.vw-tabs .seg-btn { min-height: 30px; padding: 0 14px; }

/* capacity: a label line over a thin meter (labels never sit on the fill: readable in both themes) */
.vw-cap { display: flex; justify-content: space-between; gap: var(--s-2); margin-bottom: -3px; font-size: var(--fs-xs); font-weight: 800; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.vw-cap.warn { color: var(--warn); }
.vw-meter { position: relative; height: 8px; border: 1px solid var(--border); background: var(--surface-sunken); }
.vw-meter i { position: absolute; left: 0; top: 0; bottom: 0; max-width: 100%; background: var(--primary); }
.vw-meter.weight i { background: var(--weight); }
.vw-meter.slots i { background: var(--exp); }
.vw-meter.warn i { background: var(--meter-warn); }
.vw-pane .vault-prem, .vw-pane .warn-card { margin: 0; }
.vw-pane .warn-card { padding: 8px 10px; border-radius: 0; }

.vw-tools { display: flex; gap: 6px; }
.vw-search { flex: 1 1 auto; min-width: 0; }
.vw-search input { min-height: 34px; }
.vw-sort { flex: none; max-width: 46%; min-height: 34px; }
.vw-chips { gap: 4px; margin: 0; }
.vw-chips:empty { display: none; }
.vw-chips .chip { min-height: 28px; padding: 0 9px; }
.chip-c { margin-left: 4px; font-size: var(--fs-micro); font-weight: 800; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chip.on .chip-c { color: inherit; }
.chip.none:not(.on) { opacity: 0.55; }

/* ---------------------------------------------------------------- rows */
.vw-list { flex: 1; min-height: 0; margin: 0; padding: 0; list-style: none; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--border-soft); background: var(--surface-1); }
.vw-list:empty { display: none; }
.vrow { display: flex; align-items: stretch; border-bottom: 1px solid var(--hairline-2); }
.vrow-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 5px 8px; margin: 0;
  font: inherit; color: var(--text); text-align: left; cursor: pointer; background: transparent; border: 0; border-radius: 0;
}
.vrow-main:hover { background: var(--sel-softer); }
.vrow-main:focus-visible, .vrow-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.vrow-main.is-worn { cursor: default; }
.vrow-main.is-worn:hover { background: transparent; }
.vrow-ico { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--border-soft); background: var(--tile-bg); }
.vrow-ico .ico, .vq-ico .ico { display: block; }
:is(.vrow-ico, .vq-ico).r-good { border-color: var(--r-good-line); background-image: linear-gradient(180deg, transparent 40%, var(--r-good-tint)), var(--tile-bg); }
:is(.vrow-ico, .vq-ico).r-rare { border-color: var(--r-rare-line); background-image: linear-gradient(180deg, transparent 35%, var(--r-rare-tint)), var(--tile-bg); }
:is(.vrow-ico, .vq-ico).r-unique { border-color: var(--r-unique-line); background-image: linear-gradient(180deg, transparent 30%, var(--r-unique-tint)), var(--tile-bg); }
:is(.vrow-ico, .vq-ico).r-signature { border-color: var(--r-signature-line); background-image: linear-gradient(180deg, transparent 30%, var(--r-signature-tint)), var(--tile-bg); }
:is(.vrow-ico, .vq-ico).r-forged { border-color: var(--r-forged-line); background-image: linear-gradient(180deg, transparent 35%, var(--r-forged-tint)), var(--tile-bg); }
:is(.vrow-ico, .vq-ico).r-card { border-color: var(--r-card-line); background-image: linear-gradient(180deg, transparent 40%, var(--r-card-tint)), var(--tile-bg); }
:is(.vrow-ico, .vq-ico).r-egg { border-color: var(--r-egg-line); background-image: linear-gradient(180deg, transparent 40%, var(--r-egg-tint)), var(--tile-bg); }
:is(.vrow-ico, .vq-ico).r-costume { border-color: var(--r-costume-line); background-image: linear-gradient(180deg, transparent 40%, var(--r-costume-tint)), var(--tile-bg); }
.vrow-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.vrow-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vrow-name:not([class*="r-"]) { color: var(--text-strong); }
.vrow-sub { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vrow-sub .pill { padding: 0 6px; font-size: var(--fs-micro); }
.vrow-lock .lock-ico { margin-left: 5px; vertical-align: -2px; }
.vrow-qty { flex: none; font-size: var(--fs-sm); font-weight: 800; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.vrow-go {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; font-size: 17px; font-weight: 900; line-height: 1;
  color: var(--primary-text); background: var(--surface-2); border: 1px solid var(--border);
}
.vrow-main:hover .vrow-go, .vrow-main:focus-visible .vrow-go { color: var(--text-on-primary); background: var(--primary); border-color: var(--primary-line); }
.vrow-btn {
  flex: none; width: 42px; margin: 0; padding: 0; font: inherit; font-weight: 900; color: var(--text-muted); cursor: pointer;
  background: transparent; border: 0; border-left: 1px solid var(--hairline-2); border-radius: 0;
}
.vrow-btn:hover { color: var(--sel-text); background: var(--sel-softer); }
.vrow-pad, .vrow-pad:hover { cursor: default; background: transparent; }
.vrow-act { align-self: center; margin: 0 8px 0 2px; }
.vrow.no .vrow-main { opacity: 0.6; }
.vrow-why { font-weight: 800; color: var(--warn); }
.vrow.no .vrow-main:hover .vrow-go { color: var(--text-muted); background: var(--surface-2); border-color: var(--border); }
.vw-empty { flex: 1; padding: 18px 14px; text-align: center; font-size: var(--fs-sm); color: var(--text-muted); border: 1px dashed var(--border); background: var(--surface-1); }

.vw-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding-top: 1px; }
.vw-bulk-l { margin-right: 2px; font-size: var(--fs-micro); font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }
.vw-bulk .btn { min-height: 28px; }
.vw-foot { color: var(--text-muted); text-align: center; line-height: 1.35; }
.vw-foot b { color: var(--text-soft); }

/* ---------------------------------------------------------------- the amount dialog */
.modal.vault-qty { width: min(400px, 100%); gap: 12px; }
.vq-head { display: flex; align-items: center; gap: 12px; }
.vq-ico { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--border); background: var(--tile-bg); }
.modal.vault-qty .vq-title { margin: 0 0 2px; font-size: var(--fs-lg); }
.vq-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.vq-quick .btn { flex: 1 1 auto; justify-content: center; }
.vq-quick .btn b { margin-left: 5px; font-variant-numeric: tabular-nums; }
.vq-amount { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text-soft); }
.vq-amount input { width: 150px; }
.vq-range { width: 100%; accent-color: var(--sel); }
.modal.vault-qty .btn.primary b { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- the reduced Vaultkeepers panel (an NPC card) */
.vault-sum { display: flex; gap: var(--s-5); margin-bottom: var(--s-2); }
.vault-sum b { font-size: var(--fs-xl); color: var(--text-strong); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- phones: one pane at a time behind a switch */
@media (max-width: 760px) {
  .modal-wrap.plain:has(> .vault-win) { padding: 0; }
  .modal.vault-win { width: 100%; height: 100dvh; padding: 8px 10px; gap: 8px; border: 0; outline: 0; }
  .vw-head .npc-portrait { width: 36px; height: 36px; }
  .vw-title .h3 { font-size: var(--fs-lg); }
  .vw-switch { display: flex; }
  .vw-switch .seg-btn { flex: 1; justify-content: center; min-height: 38px; }
  .vw-panes { grid-template-columns: minmax(0, 1fr); }
  .vw-panes[data-side="bag"] .vw-vault, .vw-panes[data-side="vault"] .vw-bag { display: none; }
  .vw-pane { padding: 8px; }
  .vw-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .vw-chips .chip { flex: none; min-height: 32px; }
  .vrow-main { min-height: 50px; }
  .vw-foot { display: none; }
}
