/* Inventory panel (js/inventory.js) - modelled on the game's own inventory window */
.inventory { padding: 20px 22px 22px; border: 1px solid rgba(190,150,80,.42);
  background: radial-gradient(ellipse at 85% 0%, rgba(190,150,80,.1), transparent 24rem), rgba(0,0,0,.22); }
.inventory .forge-intro h3 { color: #f0c48a; }
.inv-layout { display: flex; flex-wrap: wrap; gap: 18px 26px; align-items: flex-start; margin-top: 10px; }
.inv-left, .inv-right { min-width: 0; }
.inv-right { flex: 1 1 340px; }
.inv-equip { position: relative; background: #0a0b0c; border: 1px solid #3a3228; box-shadow: inset 0 0 0 1px rgba(0,0,0,.6); }
.inv-slot { position: absolute; box-sizing: border-box; border: 1px solid #2c2620; background: linear-gradient(135deg, #14110e, #0c0a09); }
.inv-slot > span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 2px; text-align: center;
  font: 600 .58rem/1.1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: #4a4036; pointer-events: none; }
.inv-slot.filled { border-color: #5a4a30; }
.inv-scroll { max-height: 280px; overflow: auto; border: 1px solid #3a3228; background: #080807; padding: 0; }
.inv-scroll.small { max-height: 170px; margin-top: 4px; }
.inv-grid { position: relative; background-image:
    linear-gradient(to right, rgba(120,96,56,.22) 1px, transparent 1px), linear-gradient(to bottom, rgba(120,96,56,.22) 1px, transparent 1px); }
.inv-item { position: absolute; box-sizing: border-box; padding: 0; margin: 0; border: 1px solid rgba(140,110,60,.55); border-radius: 0;
  background: rgba(36,28,20,.85); cursor: pointer; overflow: hidden; }
.inv-item img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.inv-item:hover { border-color: #e0a85a; box-shadow: 0 0 8px rgba(224,168,90,.45); z-index: 2; }
.inv-item.sel { border-color: #6fdc8c; box-shadow: 0 0 0 1px #6fdc8c, 0 0 10px rgba(111,220,140,.45); z-index: 3; }
.inv-item.forgeable::after { content: ""; position: absolute; right: 0; top: 0; border-style: solid; border-width: 0 9px 9px 0; border-color: transparent #e08a3c transparent transparent; opacity: .85; }
.inv-stack { position: absolute; right: 2px; bottom: 1px; font: 700 .68rem/1 var(--font-mono); color: #f4ecd8; text-shadow: 0 0 2px #000, 0 0 3px #000, 1px 1px 0 #000; font-style: normal; }
.inv-bagmark { position: absolute; left: 2px; bottom: 0; font-style: normal; font-size: .7rem; color: #e9d7a8; text-shadow: 0 0 3px #000; }
.inv-noicon { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font: 600 .62rem var(--font-ui); color: #8a7a60; text-transform: uppercase; }
.inv-hint { margin: 0; font-size: .8rem; color: var(--ink-faint); }
.inv-selbar { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 3px; background: rgba(0,0,0,.28); }
.inv-sel { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inv-sel-icon { position: relative; width: 44px; height: 64px; flex: none; background: #0b0e10; border: 1px solid var(--line-strong); }
.inv-sel-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.inv-sel-main { flex: 1; min-width: 160px; display: grid; gap: 2px; }
.inv-sel-main b { font-size: .95rem; }
.inv-sel-main small { color: var(--ink-dim); font-size: .74rem; }
.inv-sel-main .why { color: #e9b27a; }

/* the hover card: the game's item description, floating by the cursor */
.inv-tip { position: fixed; z-index: 400; width: min(340px, 90vw); padding: 12px 14px; border: 1px solid #8a6a38; border-radius: 3px;
  background: linear-gradient(180deg, #1d1710, #0f0c08); box-shadow: 0 6px 22px rgba(0,0,0,.65); pointer-events: none; font-size: .8rem; color: #d8cdb6; max-height: calc(100vh - 92px); overflow: hidden; box-sizing: border-box; }
.inv-tip[hidden] { display: none; }
.tip-name { font: 700 1rem/1.25 var(--font-ui); color: #f4ecd8; }
.tip-meta { margin: 2px 0 6px; font-size: .72rem; color: #9a8a6a; }
.tip-unid { color: #e0a85a; font-style: italic; margin-bottom: 4px; }
.tip-desc { margin: 6px 0; line-height: 1.4; color: #cfc3a8; }
.tip-h { margin: 8px 0 3px; font: 700 .68rem var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: #9a8a6a; }
.tip-props { margin: 0; padding: 0 0 0 16px; display: grid; gap: 2px; color: #8fd0ff; }
.tip-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(138,106,56,.4); font: .72rem var(--font-mono); color: #9a8a6a; }
.tip-flag { margin-top: 4px; color: #e0a85a; font-size: .72rem; }
.tip-flag.bad { color: #f0a286; }
.tip-smithy { margin-top: 6px; color: #e08a3c; font-size: .72rem; }

/* ---- paper doll ---- */
.inv-layout { align-items: flex-start; }
.inv-left .est-h, .inv-right .est-h { margin-top: 0; }
.doll { --s: 58px; --g: 8px; display: grid; grid-template-columns: var(--s) 126px var(--s); gap: var(--g); padding: 14px;
  border: 1px solid rgba(217,179,106,.28); border-radius: 10px;
  background: radial-gradient(ellipse at 50% 30%, rgba(217,179,106,.07), transparent 65%), linear-gradient(180deg, #121010, #0a0909); }
.doll-col { display: grid; grid-auto-rows: var(--s); gap: var(--g); align-content: start; }
.doll-mid { display: grid; grid-template-rows: 1fr auto; gap: var(--g); min-height: 0; }
.doll-fig { display: flex; align-items: center; justify-content: center; color: rgba(217,179,106,.2); }
.doll-fig svg { height: 100%; max-height: 196px; width: auto; }
.doll-hands { display: grid; grid-template-columns: 1fr 1fr; gap: var(--g); }
.doll-hands .doll-slot { height: 118px; width: auto; }
.doll-ammo { grid-column: 1 / -1; display: flex; justify-content: center; gap: var(--g); padding-top: 10px; margin-top: 2px; border-top: 1px solid rgba(217,179,106,.14); }
.doll-ammo .doll-slot { width: 46px; height: 46px; }
.doll-slot { position: relative; box-sizing: border-box; width: var(--s); height: var(--s); border-radius: 8px;
  border: 1px solid rgba(217,179,106,.22); background: linear-gradient(145deg, rgba(30,26,21,.9), rgba(13,12,10,.95));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), inset 0 0 14px rgba(0,0,0,.6); transition: border-color .15s, box-shadow .15s; }
.doll-slot > em { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font: 600 .5rem/1 var(--font-ui); letter-spacing: .1em;
  text-transform: uppercase; font-style: normal; color: rgba(217,179,106,.3); pointer-events: none; }
.doll-slot.filled { border-color: var(--edge, rgba(217,179,106,.6)); box-shadow: inset 0 0 14px rgba(0,0,0,.5), 0 0 12px color-mix(in srgb, var(--edge, #d9b36a) 28%, transparent); }
.doll-slot.filled > em { display: none; }
.doll-slot .inv-item { inset: 0; width: 100%; height: 100%; left: 0; top: 0; border: 0; border-radius: 8px; background: transparent; }
.doll-slot .inv-item:hover { box-shadow: none; filter: brightness(1.2); }
.doll-slot .inv-item.sel { box-shadow: 0 0 0 2px #6fdc8c, 0 0 12px rgba(111,220,140,.5); }
.doll-slot .inv-item.forgeable::after { right: 3px; top: 3px; border-width: 0 8px 8px 0; border-radius: 0 3px 0 0; }
.inv-fit { position: absolute; inset: 6px; display: flex; align-items: center; justify-content: center; }
.inv-fit-box { position: relative; height: 100%; max-width: 100%; }
.inv-fit-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.inv-scroll { height: 292px; max-height: none; box-sizing: content-box; width: 320px; max-width: 100%; border: 1px solid rgba(217,179,106,.28); border-radius: 10px;
  background: linear-gradient(180deg, #0c0b0a, #080807); }
.inv-scroll.small { height: auto; max-height: 170px; }
.inv-grid { border-radius: 10px; }
@media (max-width: 760px) { .doll { margin: 0 auto; } }

/* ---- no figure; the pack fills the rest of the panel ---- */
.inv-layout { align-items: stretch; flex-wrap: nowrap; }
.inv-left { flex: none; }
.inv-right { flex: 1 1 0; min-width: 300px; display: flex; flex-direction: column; }
.doll-mid { min-height: 0; }
.doll-hands { height: 100%; }
.doll-hands .doll-slot { height: 100%; }
.inv-scroll { flex: 1 1 auto; width: auto; max-width: none; height: auto; min-height: 292px; box-sizing: border-box; container-type: inline-size; overflow-y: auto; overflow-x: hidden; }
.inv-scroll.small { flex: none; max-height: 190px; min-height: 0; }
.inv-grid { --c: calc((100cqw - 10px) / var(--cols)); position: relative; width: calc(var(--c) * var(--cols)); height: calc(var(--c) * var(--rows));
  background-size: var(--c) var(--c); }
@media (max-width: 760px) { .inv-layout { flex-wrap: wrap; } .inv-right { flex-basis: 100%; } }

/* an item picture keeps its proportions: the largest box of the item's own shape that fits the slot */
.inv-fit { container-type: size; }
.inv-fit-box { height: auto; max-width: none; width: min(100cqw, calc(100cqh * var(--r, 1))); aspect-ratio: var(--r, 1); }

/* cells keep one fixed size (so pictures are never scaled much or stretched); a wider box simply shows more empty cells */
.inv-grid { --c: 34px; width: 100%; min-width: calc(var(--c) * var(--cols)); height: auto; min-height: calc(var(--c) * var(--rows)); background-size: var(--c) var(--c); }
.inv-scroll > .inv-grid { min-height: max(100%, calc(var(--c) * var(--rows))); }

/* ---- rearranging ---- */
.inv-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.inv-sort { flex: 1 1 200px; min-width: 0; padding: 7px 10px; border: 1px solid rgba(217,179,106,.3); border-radius: 6px; background: #0c0b0a; color: var(--ink-bone); font: .8rem var(--font-ui); }
.inv-tools .btn { padding: 7px 12px; font-size: .78rem; }
.inv-note { margin: 6px 0 0; font-size: .72rem; color: var(--ink-faint); }
.inv-item { touch-action: none; }
.inv-item.dragging { opacity: .35; }
.inv-drop { position: absolute; pointer-events: none; z-index: 5; border: 2px dashed; border-radius: 3px; box-sizing: border-box; }
.inv-drop.ok { border-color: #6fdc8c; background: rgba(111,220,140,.14); }
.inv-drop.bad { border-color: #e0654a; background: rgba(224,101,74,.16); }

/* ---- one real grid of 10 columns (no filler columns), cut into pages ---- */
.inv-layout { flex-wrap: wrap; align-items: stretch; }
.inv-right { flex: 0 0 auto; min-width: 0; }
.inv-scroll { flex: 1 1 auto; width: calc(32px * 10 + 16px); max-width: 100%; }
.inv-grid { --c: 32px; width: calc(var(--c) * var(--cols)); min-width: 0; min-height: calc(var(--c) * var(--rows)); height: calc(var(--c) * var(--rows)); }
.inv-scroll > .inv-grid { min-height: calc(var(--c) * var(--rows)); }
.inv-page { position: absolute; left: 0; right: 0; box-sizing: border-box; pointer-events: none; border-top: 1px dashed rgba(217,179,106,.55); }
.inv-page:first-child { border-top-color: transparent; }
.inv-pagetag { position: absolute; right: 4px; top: -1px; transform: translateY(-50%); pointer-events: auto; z-index: 6; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--pc, rgba(217,179,106,.5)); background: #14110d; color: var(--pc, #d9b36a); font: 600 .6rem/1.3 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.inv-page:first-child .inv-pagetag { transform: translateY(2px); }
.inv-pagetag i { font-style: normal; opacity: .6; }
.inv-pagetag:hover { background: #1e1912; }
.inv-pageedit { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 8px; padding: 8px 10px; border: 1px solid rgba(217,179,106,.3); border-radius: 8px; background: rgba(0,0,0,.28); }
.inv-pageedit b { font-size: .8rem; color: #e9d7a8; }
.inv-pagename { flex: 1 1 130px; min-width: 0; padding: 6px 9px; border: 1px solid rgba(126,152,164,.3); border-radius: 5px; background: #090c0e; color: var(--ink-bone); font: .82rem var(--font-ui); }
.inv-swatches { display: inline-flex; align-items: center; gap: 5px; }
.inv-sw { width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 2px solid transparent; background: var(--sw, #222); cursor: pointer; color: #aaa; font-size: .7rem; line-height: 1; }
.inv-sw.none { background: #14110d; border-color: rgba(217,179,106,.3); }
.inv-sw.sel { border-color: #fff; box-shadow: 0 0 6px var(--sw, #fff); }
.inv-pickcolor { width: 26px; height: 22px; padding: 0; border: 1px solid rgba(217,179,106,.3); border-radius: 4px; background: none; cursor: pointer; }
.inv-pageedit .btn { padding: 5px 12px; font-size: .75rem; }

/* a slimmer doll so doll + pack sit side by side on ordinary screens */
.doll { --s: 54px; grid-template-columns: var(--s) 112px var(--s); padding: 12px; }
.inv-layout { gap: 16px 20px; }
.inv-right { flex: 0 0 auto; width: calc(32px * 10 + 16px); max-width: 100%; }

/* ---- side by side: the doll on the left, the pack (options on top, abbreviated) filling the right ---- */
.inv-layout { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 14px 22px; align-items: stretch; }
.inv-right { width: auto; max-width: 560px; min-width: 0; display: flex; flex-direction: column; }
.inv-tools { flex-wrap: nowrap; gap: 6px; }
.inv-sort { flex: 1 1 auto; min-width: 0; }
.inv-tools .btn { flex: none; padding: 7px 11px; }
.inv-scroll { width: 100%; max-width: none; flex: 1 1 auto; container-type: inline-size; }
.inv-grid { --c: calc((100cqw - 12px) / var(--cols)); width: calc(var(--c) * var(--cols)); min-width: 0; height: calc(var(--c) * var(--rows)); min-height: 0; background-size: var(--c) var(--c); }
.inv-scroll > .inv-grid { min-height: calc(var(--c) * var(--rows)); }
@media (max-width: 860px) { .inv-layout { grid-template-columns: 1fr; } .inv-right { max-width: none; } }

/* ---- home containers ---- */
.inv-homes { margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(217,179,106,.2); }
.home-group { margin-top: 10px; }
.home-group h6 { margin: 0 0 6px; font: 600 .86rem var(--font-ui); color: #e9d7a8; }
.home-group h6 small { font-weight: 400; color: var(--ink-faint); margin-left: 6px; }
.home-box { margin-bottom: 6px; border: 1px solid rgba(217,179,106,.22); border-radius: 8px; background: rgba(0,0,0,.2); }
.home-box > summary { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; list-style: none; font-size: .86rem; color: var(--ink-bone); }
.home-box > summary::-webkit-details-marker { display: none; }
.home-box > summary::before { content: "▸"; color: #d9b36a; font-size: .8rem; }
.home-box[open] > summary::before { content: "▾"; }
.home-box > summary small { color: var(--ink-faint); margin-left: auto; }
.home-box > summary em { font-style: normal; font-size: .68rem; color: #ffd08a; border: 1px solid rgba(224,138,60,.5); border-radius: 999px; padding: 2px 8px; }
.home-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(217,179,106,.4); background: transparent; flex: none; }
.home-body { padding: 4px 12px 12px; }
.home-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.home-name { flex: 1 1 170px; min-width: 0; padding: 6px 9px; border: 1px solid rgba(126,152,164,.3); border-radius: 5px; background: #090c0e; color: var(--ink-bone); font: .82rem var(--font-ui); }
.home-edit .btn { padding: 5px 11px; font-size: .75rem; }
.home-pick { width: 26px; height: 22px; padding: 0; border: 1px solid rgba(217,179,106,.3); border-radius: 4px; background: none; cursor: pointer; }
.inv-scroll.small { max-height: 260px; border-radius: 8px; }
.inv-grid.home { background-color: color-mix(in srgb, var(--tint, transparent) 22%, #080807); }
.inv-scroll.small .inv-grid { --c: calc((100cqw - 12px) / var(--cols)); }
.inv-scroll { scrollbar-width: thin; scrollbar-color: rgba(217,179,106,.4) transparent; }
.inv-grid, .inv-scroll.small .inv-grid { --c: calc((100cqw - 10px) / var(--cols)); }

/* ---- resizable pack: drag the right edge, the bottom edge or the corner ---- */
.inv-right { position: relative; }
.inventory.sized .inv-layout { grid-template-columns: max-content var(--invw, minmax(0, 560px)); }
.inventory.sized .inv-right { width: var(--invw, auto); max-width: none; }
.inventory.sized .inv-right .inv-scroll { height: var(--invh, auto); flex: none; }
.inv-edge { position: absolute; z-index: 8; background: transparent; }
.inv-edge-r { top: 0; bottom: 0; right: -9px; width: 14px; cursor: ew-resize; }
.inv-edge-b { left: 0; right: 0; bottom: -9px; height: 14px; cursor: ns-resize; }
.inv-edge-c { right: -9px; bottom: -9px; width: 18px; height: 18px; cursor: nwse-resize; z-index: 9; }
.inv-edge::after { content: ""; position: absolute; background: rgba(217,179,106,.0); border-radius: 3px; transition: background .15s; }
.inv-edge-r::after { top: 30%; bottom: 30%; left: 5px; width: 4px; }
.inv-edge-b::after { left: 30%; right: 30%; top: 5px; height: 4px; }
.inv-edge-c::after { right: 4px; bottom: 4px; width: 9px; height: 9px; border-right: 2px solid rgba(217,179,106,.0); border-bottom: 2px solid rgba(217,179,106,.0); background: none; border-radius: 0; }
.inv-edge:hover::after, .inv-right:hover .inv-edge::after { background: rgba(217,179,106,.45); }
.inv-right:hover .inv-edge-c::after, .inv-edge-c:hover::after { background: none; border-color: rgba(217,179,106,.7); }
@media (max-width: 860px) { .inventory.sized .inv-layout { grid-template-columns: 1fr; } .inventory.sized .inv-right { width: auto; } .inv-edge-r, .inv-edge-c { display: none; } }

/* by default the pack box is exactly as tall as the doll beside it (and scrolls); a dragged height overrides that */
.inv-right { height: 0; min-height: 100%; }
.inv-right .inv-scroll { flex: 1 1 0; min-height: 160px; height: auto; }
.inventory.sized .inv-right.hsized, .inventory.hsized .inv-right { height: auto; min-height: 0; }
.inventory.hsized .inv-right .inv-scroll { height: var(--invh); flex: none; }
@media (max-width: 860px) { .inv-right { height: auto; min-height: 0; } .inv-right .inv-scroll { height: 360px; flex: none; } }

/* ---- page tabs live in a gutter to the right of the grid, not on top of it ---- */
.inv-gw { display: flex; align-items: flex-start; gap: 4px; }
.inv-gw .inv-grid { flex: none; }
.inv-gutter { position: relative; flex: none; width: 22px; height: calc(var(--c) * var(--rows)); }
.inv-gw { --c: calc((100cqw - 10px - 26px) / var(--cols)); }
.inv-gw .inv-grid { --c: calc((100cqw - 10px - 26px) / var(--cols)); }
.inv-gw .inv-gutter { --c: calc((100cqw - 10px - 26px) / var(--cols)); }
.inv-pagetag { position: absolute; left: 0; right: auto; transform: none; width: 22px; padding: 6px 0; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 4px;
  writing-mode: vertical-rl; text-orientation: mixed; transform: rotate(180deg); overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  border-radius: 0 7px 7px 0; border: 1px solid var(--pc, rgba(217,179,106,.4)); border-left: 0;
  background: color-mix(in srgb, var(--pc, #d9b36a) 14%, #14110d); color: var(--pc, #d9b36a); pointer-events: auto; }
.inv-page:first-child .inv-pagetag { transform: rotate(180deg); }
.inv-pagetag i { font-style: normal; opacity: .6; transform: rotate(0deg); }
.inv-pagetag:hover { background: color-mix(in srgb, var(--pc, #d9b36a) 28%, #14110d); }
.inv-page { border-top-style: dashed; }

.tip-scrollhint { position: sticky; bottom: -12px; margin: 8px -14px -12px; padding: 6px 14px; text-align: center; font-size: .7rem; color: #e9c98f;
  background: linear-gradient(180deg, rgba(15,12,8,0), #0f0c08 45%); }
