/* The bag (Túi đồ) and the coffee beans: frosted glass where the people panel sits, which it replaces while
   open; a sheet from the bottom on a phone. Warm amber and coffee brown, never red. Everything arrives with a
   250 to 300 ms ease and takes its room from the start, so nothing around it moves. */

:root { --bean: #8a5530; --bean-line: #f6e7d0; }
@media (prefers-color-scheme: dark) { :root { --bean: #d9a066; --bean-line: #3a2616; } }
.bean { flex: none; width: 18px; height: 18px; fill: var(--bean); }
.bean path { fill: none; stroke: var(--bean-line); stroke-width: 1.6; stroke-linecap: round; }
.bean.big { width: 28px; height: 28px; }
.bean.drop { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; will-change: transform; }

/* ---- the counter in the top bar */
.bean-chip { display: none; align-items: center; gap: 8px; flex: none; min-width: 9.6em; height: 34px; padding: 0 14px 0 10px; border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line)); border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, var(--panel)); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: border-color .25s ease, background .25s ease; }
.bean-chip.on { display: inline-flex; animation: resident-in .25s ease both; }
.bean-chip:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 24%, var(--panel)); }
.bean-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.bean-text b { font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.bean-text small { color: var(--hud-muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bean-chip.full { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 26%, var(--panel)); animation: resident-in .25s ease both, bean-pulse 2.8s ease-in-out 1s infinite; }
@keyframes bean-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent); } }
@media (max-width: 1400px) { header:has(.bean-chip.on) .summary { display: none; } }

/* ---- the panel */
.bag { position: fixed; z-index: 17; right: var(--gap); top: calc(var(--bar, 50px) + 2 * var(--gap)); bottom: var(--gap); width: 344px; display: flex; flex-direction: column; overflow: hidden; opacity: 0; visibility: hidden; transform: translateX(14px); transition: opacity .25s ease, transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s .3s; }
.bag.on { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
body.in-room .bag { bottom: calc(var(--bottom-hud, 0px) + 2 * var(--gap)); }
body.bag-open .side, body.bag-open .side-tab, body.bag-open .resident-panel { display: none !important; }
.bg-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px 16px; border-bottom: 1px solid var(--hud-line); }
.bg-head b { flex: 1; font-size: 14px; }

/* wallet, chest, claim */
.bg-beans { flex: none; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px; padding: 10px 16px; border-bottom: 1px solid var(--hud-line); }
.bg-wallet { display: flex; align-items: center; gap: 8px; min-width: 5.6em; }
.bg-wallet > span { display: flex; flex-direction: column; line-height: 1.15; }
.bg-wallet b { font-size: 19px; font-variant-numeric: tabular-nums; transform-origin: left center; }
.bg-wallet small { color: var(--hud-muted); font-size: 11.5px; }
.bg-chest { min-width: 0; }
.bg-chest-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--hud-muted); }
.bg-chest-top b { color: var(--ink); font-variant-numeric: tabular-nums; }
.bg-bar { height: 8px; margin-top: 5px; overflow: hidden; border-radius: 4px; background: color-mix(in srgb, var(--ink) 12%, transparent); }
.bg-bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transform-origin: left; transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.bg-chest.full .bg-chest-top span { color: var(--ink); font-weight: 650; }
.bag .bg-claim { min-width: 72px; min-height: 44px; justify-content: center; }
.bg-claim:disabled { background: transparent; color: var(--hud-muted); border-style: dashed; cursor: default; }
.bg-said { grid-column: 1 / -1; min-height: 1.3em; color: var(--hud-muted); font-size: 12px; }

/* the turning picture and what is worn */
.bg-me { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
.bg-preview { flex: none; width: 112px; height: 140px; border-radius: 12px; background: radial-gradient(ellipse at 50% 85%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%); }
.bg-status { flex: 1; display: flex; flex-wrap: wrap; align-content: center; gap: 6px 8px; min-width: 0; font-size: 12.5px; color: var(--hud-muted); }
.bg-status span { flex: 1 1 100%; min-height: 3.1em; }
.bg-chip { min-height: 32px; padding: 3px 12px; border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line)); border-radius: 999px; background: color-mix(in srgb, var(--accent) 14%, var(--panel)); color: var(--ink); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.bg-chip:hover { background: color-mix(in srgb, var(--accent) 26%, var(--panel)); }
.bg-chip[hidden] { display: none; }

/* tabs */
.bg-tabs { flex: none; display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--hud-line); }
.bg-tabs[hidden] { display: none; }
.bg-tab { flex: 1; min-height: 44px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--hud-muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: color .2s ease, border-color .2s ease; }
.bg-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.bg-tab:hover { color: var(--ink); }
.bg-pane { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 6px; }
.bg-pane[hidden] { display: none; }

/* my things */
.bg-group h3 { margin: 12px 4px 8px; font-size: 12.5px; font-weight: 650; }
.bg-desk-note { margin: -4px 4px 8px; color: var(--hud-muted); font-size: 11.5px; }
.bg-empty { margin: 12px 4px 0; color: var(--hud-muted); font-size: 12.5px; }
.bg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bg-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 112px; padding: 8px 4px 7px; border: 1px solid var(--hud-line); border-radius: 12px; background: color-mix(in srgb, var(--panel) 70%, transparent); color: var(--ink); font: inherit; cursor: pointer; transition: border-color .2s ease, background .2s ease, transform .2s cubic-bezier(.2, .8, .2, 1); }
.bg-item:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); transform: translateY(-1px); }
.bg-item img { width: 56px; height: 56px; object-fit: contain; }
.bg-item img[hidden] { display: block; visibility: hidden; }
.bg-name { font-size: 12px; font-weight: 600; line-height: 1.25; text-align: center; }
.bg-src, .bg-lock { display: flex; align-items: center; gap: 3px; justify-content: center; color: var(--hud-muted); font-size: 10.5px; line-height: 1.2; text-align: center; }
.bg-lock .ui-ico { width: 11px; height: 11px; }
.bg-item.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--panel)); box-shadow: 0 0 0 1px var(--accent) inset; }
.bg-check { position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.bg-check .ui-ico { width: 14px; height: 14px; stroke-width: 2.6; }
.bg-new { position: absolute; top: 6px; left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 10.5px; font-weight: 700; line-height: 1.5; }
.bg-item[aria-disabled="true"] { cursor: default; background: color-mix(in srgb, var(--ink) 5%, transparent); }
.bg-item[aria-disabled="true"]:hover { transform: none; border-color: var(--hud-line); }
.bg-item[aria-disabled="true"] img { filter: grayscale(1) contrast(.85); opacity: .45; }
.bg-item[aria-disabled="true"] .bg-name { color: var(--hud-muted); }

/* the shop */
.sh-head { display: flex; flex-direction: column; gap: 1px; padding: 12px 4px 8px; }
.sh-head b { font-size: 13.5px; }
.sh-head small { min-height: 1.3em; color: var(--hud-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sh-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sh-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 8px 8px; border: 1px solid var(--hud-line); border-radius: 12px; background: color-mix(in srgb, var(--panel) 70%, transparent); text-align: center; transition: border-color .2s ease, background .2s ease; }
.sh-card.asking { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--panel)); }
.sh-card.owned { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.sh-card img { width: 68px; height: 68px; object-fit: contain; }
.sh-card img[hidden] { display: block; visibility: hidden; }
.sh-text { display: flex; flex-direction: column; align-items: center; gap: 1px; min-height: 4.3em; }
.sh-name { font-size: 13px; line-height: 1.25; }
.sh-text small { color: var(--hud-muted); font-size: 11.5px; }
.sh-price { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.sh-act { display: flex; align-items: stretch; gap: 6px; width: 100%; min-height: 44px; }
.sh-act .btn { flex: 1; min-height: 44px; justify-content: center; padding: 3px 6px; font-size: 12px; white-space: normal; line-height: 1.2; }
.sh-act .btn:disabled { background: transparent; color: var(--hud-muted); border-style: dashed; cursor: default; }
.sh-owned { display: grid; place-items: center; flex: 1; font-size: 12.5px; font-weight: 650; }
.sh-note, .sh-said { margin: 0; color: var(--hud-muted); font-size: 12px; }
.sh-note { padding: 10px 4px 0; }
.sh-said { min-height: 1.3em; padding: 6px 4px; color: var(--ink); }
.bg-said-line { flex: none; margin: 0; padding: 0 16px; min-height: 0; color: var(--hud-muted); font-size: 12px; }
.bg-said-line:not(:empty) { padding-top: 6px; }

/* the way in from the resident panel */
.rp-wardrobe { flex: none; margin: 0 16px 12px; min-height: 44px; border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line)); border-radius: 10px; background: color-mix(in srgb, var(--accent) 16%, var(--panel)); color: var(--ink); font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; }
.rp-wardrobe:hover { background: color-mix(in srgb, var(--accent) 28%, var(--panel)); }
.rp-wardrobe[hidden] { display: none; }

@media (max-height: 780px) { .bg-preview { width: 100px; height: 112px; } .bg-me { padding-block: 2px; } .bg-status span { min-height: 2.6em; } .bg-beans { padding-block: 8px; } .bag[data-tab="shop"] .bg-me { display: none; } }

/* a phone: a sheet over the lower part of the café, four things to a row */
@media (max-width: 760px) {
  .bean-chip { position: absolute; left: 0; top: calc(100% + 8px); min-width: 0; background: color-mix(in srgb, var(--accent) 22%, var(--panel)); box-shadow: 0 8px 28px #0002; }
  .bag { top: auto; left: var(--gap); right: var(--gap); bottom: var(--gap); width: auto; height: min(80vh, 660px); transform: translateY(16px); }
  body.in-room .bag { bottom: var(--gap); }
  .bg-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .bg-item { min-height: 104px; padding: 6px 2px; }
  .bg-item img { width: 46px; height: 46px; }
  .bg-name { font-size: 11px; }
  .bg-preview { width: 88px; height: 100px; }
  .bag[data-tab="shop"] .bg-me { display: none; }
  .bean-chip { height: 44px; }
  /* The shared hour's pill hangs in the same place: with the beans there, it goes under them
     (resident-ui.css keeps the chip and what opens under it clear of both rows). */
  header:has(.bean-chip.on) .shared-pill { top: calc(100% + 60px); }
  .bag .icon-btn { width: 44px; height: 44px; }
  .bg-chip { min-height: 44px; padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .bag, .bg-item, .bg-bar i, .bg-tab, .sh-card, .bean-chip { transition: none; }
  .bean-chip.on, .bean-chip.full { animation: none; }
  .bg-item:hover { transform: none; }
}
