.inventory-shell {
    gap: var(--ui-space-lg);
}

.inventory-page {
    display: grid;
    gap: var(--ui-space-lg);
    width: 100%;
}

@media (min-width: 1024px) {
    .inventory-page {
        grid-template-columns: 300px 1fr;
        align-items: flex-start;
    }
}

.main-area {
    display: flex;
    flex-direction: column;
    gap: var(--ui-space-lg);
}

.loadout-panel {
    --inventory-sticky-offset: calc(var(--ui-space-lg) + var(--ui-space-sm));
    display: flex;
    flex-direction: column;
    gap: var(--ui-space-md);
    align-self: start;
    position: relative;
}

@media (min-width: 1024px) {
    .loadout-panel {
        position: sticky;
        top: var(--inventory-sticky-offset);
        height: fit-content;
    }
}

.loadout-panel.is-sticky-mobile {
    position: sticky;
    top: var(--inventory-sticky-offset);
    z-index: 2;
    max-height: min(420px, calc(100vh - var(--inventory-sticky-offset) - var(--ui-space-md)));
    overflow-y: auto;
    scrollbar-gutter: stable both-edges;
}

.loadout-panel.has-collapsed-slots {
    overflow: visible;
}

.loadout-panel.has-collapsed-slots .loadout-slots {
    display: none;
}

.loadout-panel.has-collapsed-slots .loadout-preview {
    min-height: 220px;
}

.loadout-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ui-space-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: var(--ui-font-size-sm);
    color: var(--ui-text-muted);
}

.loadout-header-left {
    font-size: 1.05rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ui-text-primary);
}

.loadout-header-right {
    font-weight: 500;
    text-align: right;
}

.loadout-panel.is-preview .loadout-header-right {
    color: #ffd369;
}

.loadout-overlay-status {
    font-size: var(--ui-font-size-sm);
    color: var(--ui-text-muted);
    min-height: 1.25rem;
}

.loadout-overlay-status[data-status="queued"] {
    color: var(--success-500);
}

.loadout-overlay-status[data-status="cooldown"] {
    color: var(--warning-500);
}

.loadout-overlay-status[data-status="disabled"],
.loadout-overlay-status[data-status="error"],
.loadout-overlay-status[data-status="unsupported"] {
    color: var(--danger-500);
}

.loadout-preview {
    background: var(--ui-bg-surface-raised);
    border: 1px solid var(--ui-border-color);
    border-radius: var(--ui-radius-card);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 200px;
    padding: var(--ui-space-md);
}

.loadout-actions {
    display: flex;
    flex-direction: column;
    gap: var(--ui-space-sm);
}

.loadout-actions .loadout-apply {
    width: 100%;
    justify-content: center;
}

.inventory-preview-stage {
    position: relative;
    width: var(--inventory-preview-width, 160px);
    height: var(--inventory-preview-height, 160px);
}

.inventory-preview-stage img {
    position: absolute;
    left: 0;
    top: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    transform-origin: top left;
}

.loadout-slots {
    display: flex;
    flex-direction: column;
    gap: var(--ui-space-sm);
}

.slot-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ui-space-sm);
    background: var(--ui-bg-surface-raised);
    border: 1px solid var(--ui-border-color);
    border-radius: var(--ui-radius-card);
    padding: var(--ui-space-sm) var(--ui-space-md);
}

.slot-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.slot-label {
    font-size: var(--ui-font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ui-text-muted);
}

.slot-value {
    font-weight: 600;
    color: var(--ui-text-primary);
    line-height: 1.3;
}

.slot-rarity {
    font-size: var(--ui-font-size-sm);
    font-weight: 600;
    opacity: 0.9;
}

.slot-rarity[data-rarity="common"] {
    color: #c8cad0;
}

.slot-rarity[data-rarity="uncommon"] {
    color: #52c073;
}

.slot-rarity[data-rarity="rare"] {
    color: #4db6ff;
}

.slot-rarity[data-rarity="epic"] {
    color: #d67eff;
}

.slot-rarity[data-rarity="legendary"] {
    color: #ffd369;
}

.slot-actions {
    display: flex;
    align-items: center;
    gap: var(--ui-space-xs);
}

.slot-actions .ui-button {
    white-space: nowrap;
}

.slot-actions .btn-unequip {
    background: #26272a;
    border-color: rgba(154, 157, 160, 0.2);
    color: var(--ui-text-muted);
    box-shadow: none;
    filter: none;
    transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.slot-actions .btn-unequip:hover,
.slot-actions .btn-unequip:focus-visible {
    color: var(--ui-text-primary);
    border-color: rgba(79, 142, 255, 0.45);
    box-shadow: 0 10px 22px rgba(79, 142, 255, 0.15);
}

.slot-actions .btn-unequip:focus-visible {
    outline: none;
}

.toolbar-top {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ui-space-md);
    align-items: flex-start;
    justify-content: space-between;
}

.tabs-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ui-space-sm);
    padding: 0;
    border-bottom: 1px solid var(--ui-border-color);
}

.tab-btn {
    appearance: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--ui-radius-sm);
    padding: 0.4rem 0.85rem;
    background: transparent;
    color: var(--ui-text-muted);
    font-size: var(--ui-font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover,
.tab-btn:focus-visible {
    color: var(--ui-text-primary);
    background: var(--ui-bg-surface-raised);
    border-color: rgba(79, 142, 255, 0.35);
    outline: none;
}

.tab-btn.active {
    color: var(--ui-text-primary);
    background: var(--ui-bg-surface-raised);
    border-color: var(--ui-accent-primary);
    box-shadow: none;
}

.filters-wrapper {
    flex: 1;
    min-width: 260px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--ui-space-md);
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: var(--ui-space-2xs);
}

.filter-inline-btn {
    justify-content: center;
}

.filter-inline-btn.is-active {
    background: rgba(79, 142, 255, 0.24);
    border-color: rgba(79, 142, 255, 0.45);
    box-shadow: 0 8px 18px rgba(79, 142, 255, 0.2);
}

.inventory-items-section {
    gap: var(--ui-space-lg);
}

.items-grid {
    display: grid;
    gap: var(--ui-space-lg);
    grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
}

.item-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--ui-space-md);
    padding: var(--ui-space-md);
    background: var(--ui-bg-surface);
    border: 1px solid var(--ui-border-color);
    border-radius: var(--ui-radius-card);
    box-shadow: var(--ui-shadow-soft);
    cursor: pointer;
    min-height: 240px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    --rarity-color: rgba(154, 157, 160, 0.65);
    --rarity-glow: rgba(154, 157, 160, 0.18);
}

.item-card.rarity-uncommon {
    --rarity-color: #52c073;
    --rarity-glow: rgba(82, 192, 115, 0.28);
}

.item-card.rarity-rare {
    --rarity-color: #4db6ff;
    --rarity-glow: rgba(77, 182, 255, 0.32);
}

.item-card.rarity-epic {
    --rarity-color: #d67eff;
    --rarity-glow: rgba(214, 126, 255, 0.35);
}

.item-card.rarity-legendary {
    --rarity-color: #ffd369;
    --rarity-glow: rgba(255, 211, 105, 0.35);
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.6);
}

.item-card.is-previewing {
    border-color: rgba(255, 211, 105, 0.6);
    box-shadow: 0 0 0 2px rgba(255, 211, 105, 0.2), var(--ui-shadow-soft);
}

.item-card:focus-visible {
    outline: 2px solid rgba(79, 142, 255, 0.6);
    outline-offset: 4px;
}

.item-art-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    border-radius: var(--ui-radius-card);
    background: var(--ui-bg-surface-raised);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 0 18px var(--rarity-glow);
}

.item-art {
    position: relative;
    width: var(--inventory-item-width, 64px);
    height: var(--inventory-item-height, 64px);
}

.item-art img {
    position: absolute;
    inset: 0;
    max-width: 100%;
    max-height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.rarity-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    border-radius: var(--ui-radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.16);
    padding: 0.3rem 0.6rem;
    font-size: var(--ui-font-size-sm);
    font-weight: 600;
    color: var(--rarity-color);
    background: rgba(0, 0, 0, 0.45);
}

.item-info {
    flex: 1;
    min-height: 44px;
}

.item-name {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--ui-text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-sub {
    color: var(--ui-text-muted);
    font-size: var(--ui-font-size-sm);
    line-height: 1.4;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-actions {
    margin-top: auto;
}

.btn-equip {
    width: 100%;
    justify-content: center;
}

.btn-equip[disabled] {
    cursor: default;
    filter: none;
    box-shadow: var(--ui-shadow-elevated);
}

.inventory-empty,
.inventory-notice {
    align-self: stretch;
    text-align: center;
}

@media (max-width: 1023px) {
    .inventory-page {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .loadout-panel {
        gap: var(--ui-space-sm);
    }

    .loadout-panel.is-sticky-mobile {
        max-height: min(360px, calc(100vh - var(--inventory-sticky-offset) - var(--ui-space-md)));
    }

    .loadout-header-left {
        font-size: 1rem;
    }

    .loadout-preview {
        min-height: 160px;
        padding: var(--ui-space-sm);
        max-width: 240px;
        margin-inline: auto;
    }

    .loadout-actions .loadout-apply {
        min-height: 0;
    }

    .loadout-slots {
        gap: var(--ui-space-xs);
    }

    .slot-row {
        padding: var(--ui-space-xs) var(--ui-space-sm);
    }

    .slot-label {
        font-size: 0.7rem;
    }

    .toolbar-top {
        flex-direction: column;
    }

    .filters-wrapper {
        width: 100%;
    }

    .tabs-wrapper {
        width: 100%;
    }
}
