/* DEEPMINE UI v4 — bag page styles (背包 · data-mode="bag").
   Markup: bag-panel.mjs renderBagPanel. Filters: .bag-filters.seg.seg--pills > button[data-bag-filter][aria-pressed];
   sort: select[data-bag-sort]; grid: button.bag-item.rarity-* > .bag-item-frame.item-tile + .bag-item-info;
   detail: .item-detail.rarity-*; footer: .bag-stock + button[data-sell-all].
   The panel redraws on every 2 s poll, so repeated elements (tiles) carry no CSS filters or animations. */
@layer pages {
  /* ───────────── Summary + sort ───────────── */
  #sheet[data-mode="bag"] .bag-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
  }
  #sheet[data-mode="bag"] .bag-summary-copy { min-width: 0; display: grid; gap: 1px; }
  #sheet[data-mode="bag"] .bag-summary-copy strong { font-size: var(--fs-18); font-weight: 800; line-height: 1.2; color: var(--text-1); overflow-wrap: break-word; }
  #sheet[data-mode="bag"] .bag-summary-copy span { font-size: var(--fs-12); color: var(--text-3); line-height: 1.3; overflow-wrap: break-word; }
  #sheet[data-mode="bag"] .bag-sort { flex: none; display: block; max-width: 52%; }
  #sheet[data-mode="bag"] .bag-sort select {
    width: auto;
    max-width: 100%;
    padding: 6px 32px 6px 12px;
    background-color: var(--surface-1);
    background-position: right 11px center;
    border-color: var(--line-2);
    font-weight: 700;
    color: var(--text-1);
    text-overflow: ellipsis;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .05), 0 2px 0 rgb(0 0 0 / .35);
  }

  /* ───────────── Filters (pills: they wrap instead of truncating long labels) ───────────── */
  #sheet[data-mode="bag"] .bag-filters { gap: 8px; }
  #sheet[data-mode="bag"] .bag-filters > button {
    position: relative;
    max-width: 100%;
    min-height: 38px;
    gap: 7px;
    padding: 0 7px 0 14px;
    font-size: var(--fs-14);
    overflow: visible;
  }
  /* 46px hit area around the 38px pill (rows wrap with an 8px gap, so hit areas never overlap) */
  #sheet[data-mode="bag"] .bag-filters > button::after { content: ''; position: absolute; inset: -4px -2px; }
  #sheet[data-mode="bag"] .bag-filter-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #sheet[data-mode="bag"] .bag-filter-count {
    flex: none;
    min-width: 24px;
    padding: 2px 7px 0;
    border-radius: var(--r-pill);
    background: rgb(0 0 0 / .32);
    color: var(--text-2);
    font: 700 12px/20px var(--font-display);
    text-align: center;
  }
  #sheet[data-mode="bag"] .bag-filters > button[aria-pressed="true"] .bag-filter-count {
    background: rgb(58 37 7 / .16);
    color: var(--text-on-gold);
    box-shadow: inset 0 0 0 1px rgb(58 37 7 / .2);
  }

  /* ───────────── Specimen grid ───────────── */
  #sheet[data-mode="bag"] .bag-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 8px;
    margin-top: 14px;
  }
  @media (min-width: 360px) {
    #sheet[data-mode="bag"] .bag-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
  #sheet[data-mode="bag"] .bag-item {
    position: relative;
    min-width: 0;
    display: grid;
    gap: 6px;
    padding: 0;
    text-align: center;
    color: var(--text-1);
  }
  #sheet[data-mode="bag"] .bag-item-frame {
    width: 100%;
    /* the contact shadow under the specimen is baked into the frame instead of a per-tile drop-shadow filter */
    background:
      radial-gradient(36% 10% at 50% 85%, rgb(0 0 0 / .62), transparent),
      radial-gradient(75% 65% at 50% 42%, color-mix(in srgb, var(--rarity-c) 30%, transparent), transparent 72%),
      linear-gradient(180deg, #1c4636, #10291f);
    transition: transform var(--dur-1) var(--ease-out), box-shadow var(--dur-2);
  }
  #sheet[data-mode="bag"] .bag-item:active .bag-item-frame { transform: scale(.94); }
  @media (hover: hover) and (pointer: fine) {
    #sheet[data-mode="bag"] .bag-item:hover:not(:active) .bag-item-frame { transform: translateY(-2px); border-color: color-mix(in srgb, var(--rarity, var(--rarity-common)) 80%, transparent); }
  }
  #sheet[data-mode="bag"] .bag-item:focus-visible { outline: none; }
  #sheet[data-mode="bag"] .bag-item:focus-visible .bag-item-frame { outline: 2px solid var(--gold-200); outline-offset: 2px; }
  #sheet[data-mode="bag"] .bag-item-frame img { width: 76%; height: 76%; filter: none; }
  #sheet[data-mode="bag"] .bag-item .item-count { right: 4px; bottom: 6px; font-size: 12px; }
  /* epic and above: stronger halo + a corner glint (static: the grid redraws on polls) */
  #sheet[data-mode="bag"] .bag-item:is(.rarity-epic, .rarity-legendary, .rarity-mythic, .rarity-exotic) .bag-item-frame {
    border-color: color-mix(in srgb, var(--rarity) 72%, transparent);
    box-shadow:
      inset 0 1px 0 rgb(255 255 255 / .1),
      inset 0 0 0 1px color-mix(in srgb, var(--rarity) 22%, transparent),
      inset 0 -16px 20px -14px color-mix(in srgb, var(--rarity) 85%, transparent),
      0 0 16px -5px color-mix(in srgb, var(--rarity) 75%, transparent),
      var(--sh-1);
  }
  #sheet[data-mode="bag"] .bag-item:is(.rarity-epic, .rarity-legendary, .rarity-mythic, .rarity-exotic) .bag-item-frame::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: 12px;
    height: 12px;
    background: color-mix(in srgb, var(--rarity) 45%, white);
    clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  }
  #sheet[data-mode="bag"] .bag-item-info { min-width: 0; display: grid; gap: 1px; padding: 0 2px; }
  #sheet[data-mode="bag"] .bag-item-info strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--fs-13);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-1);
  }
  /* Latin/Cyrillic names ("Minerai de cuivre", "Светящийся кристалл") take two lines before the ellipsis, one size
     down so single long words ("Реликтовый") fit a four-column tile. */
  :root:not(:lang(zh)) #sheet[data-mode="bag"] .bag-item-info { padding-inline: 1px; }
  :root:not(:lang(zh)) #sheet[data-mode="bag"] .bag-item-info strong {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: var(--fs-12);
    white-space: normal;
    overflow-wrap: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
    text-wrap: balance;
  }
  #sheet[data-mode="bag"] .bag-item-rarity {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--fs-11);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: .04em;
    color: color-mix(in srgb, var(--rarity, var(--rarity-common)) 88%, white);
  }
  :root:not(:lang(zh)) #sheet[data-mode="bag"] .bag-item-rarity { letter-spacing: 0; }
  #sheet[data-mode="bag"] .bag-grid-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
    font-size: var(--fs-12);
    color: var(--text-3);
    text-align: center;
  }
  #sheet[data-mode="bag"] .bag-grid-hint .icon { flex: none; width: 15px; height: 15px; }

  /* ───────────── Empty states (title size comes from the .empty-state component) ───────────── */
  #sheet[data-mode="bag"] .bag-empty-filter { margin-top: 14px; padding: 28px 18px 24px; gap: 8px; }
  #sheet[data-mode="bag"] .bag-empty-art {
    display: grid;
    place-items: center;
    width: 104px;
    height: 104px;
    margin-bottom: 6px;
    border-radius: 50%;
    background:
      radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--rarity) 30%, #21503d), #0f281e 72%);
    border: 1px solid color-mix(in srgb, var(--rarity) 50%, transparent);
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--rarity) 7%, transparent), 0 0 34px -8px var(--rarity), var(--sh-1);
  }
  #sheet[data-mode="bag"] .bag-empty-art img { width: 70%; height: 70%; object-fit: contain; filter: drop-shadow(0 6px 6px rgb(0 0 0 / .55)); }
  #sheet[data-mode="bag"] .bag-empty-filter:not(.is-first) .bag-empty-art:not(.is-painted) img { filter: grayscale(.55) brightness(.75) drop-shadow(0 6px 6px rgb(0 0 0 / .55)); }
  /* painted illustration (art-manifest 'empty' group): no medallion, just a warm glow behind it */
  #sheet[data-mode="bag"] .bag-empty-art.is-painted {
    width: 148px;
    height: 148px;
    margin-bottom: 0;
    border: 0;
    border-radius: 0;
    background: radial-gradient(closest-side, rgb(245 200 105 / .14), rgb(245 200 105 / .04) 60%, transparent);
    box-shadow: none;
  }
  #sheet[data-mode="bag"] .bag-empty-art.is-painted img { width: 100%; height: 100%; filter: none; }
  #sheet[data-mode="bag"] .bag-empty-filter p { max-width: 24em; text-wrap: pretty; }
  #sheet[data-mode="bag"] .bag-empty-filter .panel-empty-action { margin-top: 10px; min-width: 160px; max-width: 100%; white-space: normal; }
  #sheet[data-mode="bag"] .bag-empty-filter .btn--primary { --btn-h: 48px; font-size: var(--fs-15); }

  /* ───────────── Item detail ───────────── */
  /* back: the standard small ghost button with a left chevron */
  #sheet[data-mode="bag"] .back-link { gap: 4px; padding: 0 14px 0 8px; margin-bottom: 10px; }
  #sheet[data-mode="bag"] .back-link-arrow { display: grid; place-items: center; }
  #sheet[data-mode="bag"] .back-link-arrow .icon { width: 18px; height: 18px; transform: rotate(180deg); color: var(--gold-300); }
  #sheet[data-mode="bag"] .item-detail { --rarity-c: var(--rarity, var(--rarity-common)); display: grid; gap: 10px; min-width: 0; }
  #sheet[data-mode="bag"] .item-detail-hero {
    position: relative;
    isolation: isolate;
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 16px 16px 14px;
    border-radius: var(--r-xl);
    overflow: hidden;
    text-align: center;
    background:
      radial-gradient(70% 48% at 50% 30%, color-mix(in srgb, var(--rarity-c) 30%, transparent), transparent 72%),
      var(--grad-panel), var(--surface-1);
    border: 1px solid color-mix(in srgb, var(--rarity-c) 42%, transparent);
    box-shadow: var(--hl-top), var(--sh-2);
  }
  #sheet[data-mode="bag"] .item-detail-hero::before {
    /* static light rays behind the specimen (no animation: the panel redraws on polls) */
    content: '';
    position: absolute;
    z-index: -1;
    left: 50%;
    top: 78px;
    width: 400px;
    height: 400px;
    transform: translate(-50%, -50%);
    background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--rarity-c) 16%, transparent) 0deg 7deg, transparent 7deg 20deg);
    -webkit-mask: radial-gradient(circle, #000 0 16%, transparent 50%);
    mask: radial-gradient(circle, #000 0 16%, transparent 50%);
  }
  #sheet[data-mode="bag"] .item-detail-art {
    position: relative;
    display: grid;
    place-items: center;
    width: 124px;
    height: 124px;
    border-radius: var(--r-xl);
    background:
      radial-gradient(70% 62% at 50% 44%, color-mix(in srgb, var(--rarity-c) 34%, transparent), transparent 74%),
      linear-gradient(180deg, #1f4c3a, #0d251b);
    border: 1px solid color-mix(in srgb, var(--rarity-c) 60%, transparent);
    box-shadow:
      inset 0 1px 0 rgb(255 255 255 / .1),
      inset 0 -22px 26px -18px color-mix(in srgb, var(--rarity-c) 85%, transparent),
      0 0 30px -8px color-mix(in srgb, var(--rarity-c) 80%, transparent),
      var(--sh-2);
  }
  #sheet[data-mode="bag"] .item-detail-art img { width: 80%; height: 80%; object-fit: contain; filter: drop-shadow(0 10px 10px rgb(0 0 0 / .55)); }
  #sheet[data-mode="bag"] .item-detail-copy { position: relative; z-index: 1; min-width: 0; max-width: 100%; display: grid; justify-items: center; gap: 4px; }
  /* the rarity ribbon sits on the lower edge of the specimen frame */
  #sheet[data-mode="bag"] .item-detail-copy .rarity-label {
    margin: -26px 0 4px;
    min-height: 24px;
    padding: 1px 12px;
    font-size: var(--fs-12);
    letter-spacing: .1em;
    background: linear-gradient(180deg, color-mix(in srgb, var(--rarity-c) 30%, #12382a), color-mix(in srgb, var(--rarity-c) 16%, #0b2219));
    border-color: color-mix(in srgb, var(--rarity-c) 70%, transparent);
    box-shadow: 0 3px 8px -2px rgb(0 0 0 / .7), 0 0 12px -4px var(--rarity-c);
  }
  #sheet[data-mode="bag"] .item-detail-copy .panel-eyebrow { max-width: 100%; color: var(--text-3); letter-spacing: .12em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #sheet[data-mode="bag"] .item-detail-copy h3 { max-width: 100%; font-size: var(--fs-26); font-weight: 800; line-height: 1.15; color: var(--text-1); text-shadow: 0 2px 10px rgb(0 0 0 / .55); overflow-wrap: break-word; }
  #sheet[data-mode="bag"] .item-detail-copy p { max-width: 30em; margin-top: 2px; font-size: var(--fs-13); line-height: 1.55; color: var(--text-2); text-wrap: balance; }

  /* stats: two figures side by side, the total as a full-width gold row. Figures never wrap mid-number;
     the unit drops below when the cell is narrow. */
  #sheet[data-mode="bag"] .item-detail-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #sheet[data-mode="bag"] .item-detail-stats .stat { padding: 10px 12px 11px; display: grid; align-content: space-between; gap: 4px; }
  #sheet[data-mode="bag"] .item-detail-stats .stat-label { font-size: var(--fs-12); line-height: 1.3; overflow-wrap: break-word; }
  #sheet[data-mode="bag"] .item-detail-stats .stat-value {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 4px;
    margin-top: 0;
    font-size: var(--fs-20);
    overflow: visible;
  }
  #sheet[data-mode="bag"] .item-figure { min-width: 0; max-width: 100%; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #sheet[data-mode="bag"] .item-figure.is-long { font-size: var(--fs-16); }
  #sheet[data-mode="bag"] .item-detail-stats .stat-value span { white-space: nowrap; font-family: var(--font-ui); font-size: var(--fs-11); font-weight: 700; color: var(--text-3); }
  #sheet[data-mode="bag"] .item-detail-stats .item-detail-total {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    padding-block: 11px 12px;
  }
  #sheet[data-mode="bag"] .item-detail-total .stat-label { min-width: 0; }
  #sheet[data-mode="bag"] .item-detail-total .stat-value { margin-left: auto; justify-content: flex-end; font-size: var(--fs-22); }
  #sheet[data-mode="bag"] .item-detail-total .item-figure.is-long { font-size: var(--fs-20); }

  #sheet[data-mode="bag"] .item-detail-uses {
    display: grid;
    gap: 6px;
    padding: 12px 12px 12px 14px;
    border-radius: var(--r-lg);
    background: var(--grad-panel), var(--surface-1);
    border: 1px solid var(--line-1);
    box-shadow: var(--hl-top), var(--sh-1);
  }
  #sheet[data-mode="bag"] .item-detail-uses h4 { display: flex; align-items: center; gap: 8px; font-size: var(--fs-card-title); font-weight: 800; line-height: 1.3; color: var(--text-1); overflow-wrap: break-word; }
  #sheet[data-mode="bag"] .item-detail-uses h4 .gi { flex: none; width: 22px; height: 22px; margin: -4px 0; }
  #sheet[data-mode="bag"] .item-detail-uses p { font-size: var(--fs-13); line-height: 1.55; color: var(--text-2); text-wrap: pretty; }
  #sheet[data-mode="bag"] .item-detail-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
  #sheet[data-mode="bag"] .item-detail-actions .btn { --btn-h: 48px; width: 100%; padding-inline: 10px; font-size: var(--fs-14); white-space: normal; }
  #sheet[data-mode="bag"] .item-detail-actions .btn .gi { flex: none; }
  #sheet[data-mode="bag"] .item-detail-note { margin: 0; }
  #sheet[data-mode="bag"] .item-detail-note span { min-width: 0; text-wrap: pretty; }

  /* ───────────── Footer: stock + trade ───────────── */
  #sheet[data-mode="bag"] #sheet-footer { display: flex; align-items: center; gap: 12px; }
  #sheet[data-mode="bag"] .bag-stock { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }
  #sheet[data-mode="bag"] .bag-stock-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: var(--r-md);
    background: radial-gradient(circle at 50% 30%, #2f6a50, #163b2c 75%);
    border: 1px solid var(--line-gold);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .12), 0 3px 8px -4px rgb(0 0 0 / .8);
  }
  #sheet[data-mode="bag"] .bag-stock-icon .gi { width: 30px; height: 30px; }
  #sheet[data-mode="bag"] .bag-stock > div { min-width: 0; display: grid; gap: 1px; }
  #sheet[data-mode="bag"] .bag-stock small { font-size: var(--fs-11); font-weight: 700; color: var(--text-3); line-height: 1.2; }
  #sheet[data-mode="bag"] .bag-stock strong {
    font: 800 19px/1.1 var(--font-display);
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #sheet[data-mode="bag"] .bag-trade { flex: none; --btn-h: 48px; min-width: 128px; padding: 0 20px; font-size: var(--fs-16); }
  #sheet[data-mode="bag"] .bag-trade .gi { width: 26px; height: 26px; }
  /* 图鉴 link (progressive unlocks: shown once the collection is open) */
  #sheet[data-mode="bag"] .bag-archive { flex: none; --btn-h: 48px; gap: 6px; padding: 0 12px; font-size: var(--fs-14); }
  #sheet[data-mode="bag"] .bag-archive .gi { width: 24px; height: 24px; }
  /* a detail page with only one of the two actions (sell before the player market opens) gives it the full row */
  #sheet[data-mode="bag"] .item-detail-actions > .btn:only-child { grid-column: 1 / -1; }

  @media (max-width: 359px) {
    #sheet[data-mode="bag"] .item-detail-actions { grid-template-columns: minmax(0, 1fr); }
    #sheet[data-mode="bag"] .bag-filters { gap: 6px; }
    #sheet[data-mode="bag"] .bag-filters > button { padding: 0 6px 0 12px; gap: 5px; font-size: var(--fs-13); }
    #sheet[data-mode="bag"] .item-detail-stats { gap: 6px; }
    #sheet[data-mode="bag"] .item-detail-stats .stat { padding: 8px 10px 9px; }
    #sheet[data-mode="bag"] .item-detail-stats .stat-value { font-size: var(--fs-18); }
    #sheet[data-mode="bag"] .item-detail-stats .item-figure.is-long { font-size: var(--fs-15); }
    #sheet[data-mode="bag"] .item-detail-total .stat-value { font-size: var(--fs-20); }
    #sheet[data-mode="bag"] .item-detail-total .item-figure.is-long { font-size: var(--fs-18); }
    #sheet[data-mode="bag"] .bag-trade { min-width: 112px; padding: 0 16px; }
    #sheet[data-mode="bag"] .bag-archive { padding: 0 10px; }
    #sheet[data-mode="bag"] .bag-archive > span { display: none; }
  }

  /* Short screens: horizontal specimen hero, tighter footer and empty state. */
  @media (max-height: 740px) {
    #sheet[data-mode="bag"] .item-detail-hero {
      grid-template-columns: 108px minmax(0, 1fr);
      align-items: center;
      justify-items: start;
      gap: 14px;
      padding: 14px;
      text-align: left;
    }
    #sheet[data-mode="bag"] .item-detail-hero::before { left: 68px; top: 50%; width: 340px; height: 340px; }
    #sheet[data-mode="bag"] .item-detail-art { width: 108px; height: 108px; border-radius: var(--r-lg); }
    #sheet[data-mode="bag"] .item-detail-copy { justify-items: start; gap: 3px; }
    #sheet[data-mode="bag"] .item-detail-copy .rarity-label { order: 1; margin: 0; }
    #sheet[data-mode="bag"] .item-detail-copy .panel-eyebrow { order: 0; font-size: var(--fs-10); letter-spacing: .08em; }
    #sheet[data-mode="bag"] .item-detail-copy h3 { order: 2; font-size: var(--fs-22); }
    #sheet[data-mode="bag"] .item-detail-copy p { order: 3; font-size: var(--fs-12); line-height: 1.5; text-wrap: pretty; }
  }
  @media (max-height: 640px) {
    #sheet[data-mode="bag"] #sheet-footer { padding-block: 8px 9px; }
    #sheet[data-mode="bag"] .bag-stock-icon { width: 36px; height: 36px; border-radius: var(--r-sm); }
    #sheet[data-mode="bag"] .bag-stock-icon .gi { width: 26px; height: 26px; }
    #sheet[data-mode="bag"] .bag-stock strong { font-size: 17px; }
    #sheet[data-mode="bag"] .bag-trade { --btn-h: 44px; }
    #sheet[data-mode="bag"] .bag-empty-filter { padding: 20px 16px 18px; }
    #sheet[data-mode="bag"] .bag-empty-art { width: 84px; height: 84px; }
    #sheet[data-mode="bag"] .bag-empty-art.is-painted { width: 120px; height: 120px; }
    #sheet[data-mode="bag"] .item-detail-hero { grid-template-columns: 96px minmax(0, 1fr); }
    #sheet[data-mode="bag"] .item-detail-art { width: 96px; height: 96px; border-radius: var(--r-lg); }
  }
}

/* ── v10 (docs/v10-systems.md §1.4, §6.2): 宝箱 segment, chest detail, legacy badge, free trade cap line ──
   Markup: bag-panel.mjs renderBagV10 (button.bag-item.bag-vault-item[.is-locked], .vault-detail, .trade-cap-line) and
   chest-open.mjs (<dialog id="chest-open"> interior: .chest-header, .chest-pick-list, .chest-odds-table, .chest-result).
   Tiles redraw every 2 s: locked silhouettes use opacity only (no filters, no animations). */
@layer pages {
  #sheet[data-mode="bag"] .bag-vault-grid { grid-template-columns: repeat(auto-fill, minmax(min(30%, 96px), 1fr)); }
  #sheet[data-mode="bag"] .bag-vault-item.is-locked .bag-item-frame { border-style: dashed; background: var(--surface-inset); box-shadow: none; }
  #sheet[data-mode="bag"] .bag-vault-item.is-locked .bag-item-frame img { opacity: .16; }
  #sheet[data-mode="bag"] .bag-vault-item.is-locked .bag-item-info strong { color: var(--text-3); }
  #sheet[data-mode="bag"] .bag-vault-lock { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); }
  #sheet[data-mode="bag"] .bag-vault-lock .icon { width: 22px; height: 22px; }
  #sheet[data-mode="bag"] .bag-item-badge {
    position: absolute; left: 4px; top: 4px; max-width: calc(100% - 8px);
    padding: 1px 6px; font-size: var(--fs-10); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #sheet[data-mode="bag"] .item-detail-origin,
  #sheet[data-mode="bag"] .vault-daily { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: var(--fs-13); color: var(--text-2); }
  #sheet[data-mode="bag"] .item-detail-origin .gi { width: 20px; height: 20px; flex: none; }
  #sheet[data-mode="bag"] .item-detail-legacy { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
  #sheet[data-mode="bag"] .item-detail-legacy span { flex: 1 1 auto; min-width: 0; }
  #sheet[data-mode="bag"] .item-detail-legacy .chip { flex: none; }
  #sheet[data-mode="bag"] .item-detail-dirt { margin-top: 10px; }
  /* v10.1 D4-B: why 「在玩家市场挂售」 is still disabled (before 20,000 lifetime mined items). */
  #sheet[data-mode="bag"] .item-detail-market { margin-top: 10px; }
  #sheet[data-mode="bag"] .vault-detail.is-locked .item-detail-art img { opacity: .2; }
  #sheet[data-mode="bag"] .vault-pair .stat-label { overflow-wrap: anywhere; }
  #sheet[data-mode="bag"] .vault-starter,
  #sheet[data-mode="bag"] .vault-locked { margin: 0 0 10px; }
  #sheet[data-mode="bag"] .vault-open-actions .btn { min-width: 0; }
  #sheet[data-mode="bag"] .vault-missing { display: grid; gap: 4px; margin: 10px 0 0; padding: 0; list-style: none; font-size: var(--fs-13); line-height: 1.5; color: var(--warn); }
  #sheet[data-mode="bag"] .vault-missing li + li { color: var(--text-3); }
  #sheet[data-mode="bag"] .vault-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  #sheet[data-mode="bag"] .vault-links .btn { flex: 1 1 140px; min-width: 0; }

  /* Free trade cap line (shared with exchange-panel.mjs renderTradeCapLine) */
  .trade-cap-line { display: grid; gap: 2px; margin-top: 10px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-inset); border: 1px solid var(--line-1); font-size: var(--fs-12); line-height: 1.5; color: var(--text-2); }
  .trade-cap-line p { display: flex; align-items: center; gap: 6px; margin: 0; min-width: 0; overflow-wrap: anywhere; }
  .trade-cap-line .icon { width: 14px; height: 14px; flex: none; color: var(--text-3); }
  .trade-cap-line .trade-cap-points { padding-left: 20px; color: var(--text-3); }
  .trade-cap-line.is-warn { border-color: rgb(255 196 92 / .3); background: var(--warn-bg); }
  .trade-cap-line.is-full { border-color: rgb(255 120 90 / .32); background: var(--danger-bg); color: #ffd2c4; }

  /* ── Chest dialog (<dialog id="chest-open">, reuses the welcome-dialog frame) ── */
  .chest-emblem img { width: 100%; height: 100%; object-fit: contain; }
  .chest-body { display: grid; gap: var(--s-3); }
  .chest-pick-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
  .chest-pick {
    display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 10px; align-items: center;
    padding: 10px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line-1);
  }
  .chest-pick.is-selected { border-color: var(--line-gold-strong); }
  .chest-pick .item-tile { width: 56px; height: 56px; }
  .chest-pick .item-tile img { width: 80%; height: 80%; object-fit: contain; }
  .chest-pick-copy { display: grid; gap: 2px; min-width: 0; }
  .chest-pick-copy strong { font-size: var(--fs-15); color: var(--text-1); overflow-wrap: anywhere; }
  .chest-pick-copy small { font-size: var(--fs-12); color: var(--text-3); }
  .chest-pick-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
  .chest-pick-actions .btn { flex: 1 1 120px; min-width: 0; }
  .chest-missing { display: grid; gap: 2px; margin: 4px 0 0; padding: 0; list-style: none; font-size: var(--fs-12); line-height: 1.45; color: var(--warn); }
  .chest-missing li + li { color: var(--text-3); }
  .chest-empty { padding: var(--s-4) 0; }
  .chest-odds-section { display: grid; gap: 8px; }
  .chest-odds-section h3 { margin: 0; font-size: var(--fs-14); color: var(--text-1); }
  .chest-odds-table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
  .chest-odds-table th, .chest-odds-table td { padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--line-1); overflow-wrap: anywhere; }
  .chest-odds-table th { font-size: var(--fs-11); font-weight: 700; color: var(--text-3); }
  .chest-odds-table td:last-child, .chest-odds-table th:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--gold-100); }
  .chest-drop-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: var(--fs-13); }
  .chest-drop-list li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--text-2); }
  .chest-drop-list b { color: var(--text-1); font-weight: 700; }
  .chest-odds-note, .chest-odds-version { margin: 0; font-size: var(--fs-12); line-height: 1.5; color: var(--text-3); }
  .chest-result-items { justify-content: center; }
  .chest-result-item.is-upgrade .item-tile { border-color: var(--line-gold-strong); box-shadow: var(--glow-gold); }
  .chest-dmt { margin: 0; text-align: center; font-size: var(--fs-15); color: var(--gold-100); }
  .chest-pending { margin: 0; }
}
